Re: [R] help with paste

From: Uwe Ligges <ligges_at_statistik.uni-dortmund.de>
Date: Tue 13 Jul 2004 - 00:32:32 EST

Marc Schwartz wrote:

> On Mon, 2004-07-12 at 01:16, Andrew Criswell wrote:
>

>>Hello All:
>>
>>Suppose the following little data frame:
>>
>> > x <- data.frame(dog = c(3,4,6,2,8), cat = c(8,2,3,6,1))
>> >
>> > x$cat
>>[1] 8 2 3 6 1
>> >
>>
>>How can I get the paste() function to do the same thing. The command 
>>below is obviously wrong
>>
>> > paste(x, cat, sep = "$")

>
>
>
> You need to quote the "x" and the "cat" as explicit names, otherwise the
> objects 'x' and 'cat' are passed as arguments. 'x' in this case being
> your data frame and 'cat' being the function cat().
>
> Try this:
>
>
>>eval(parse(text = paste("x", "cat", sep = "$")))

>
> [1] 8 2 3 6 1

OK. That thread gets boring, because nobody is sure what the questioner is asking. Anyway, I guess Andrew Criswell is looking for:

    get("x")[["cat"]]

Uwe Ligges

> HTH,
>
> Marc Schwartz
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html



R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Jul 13 00:39:39 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:54:51 EST