[R] help with paste

Rolf Turner rolf at math.unb.ca
Mon Jul 12 15:57:39 CEST 2004


Andrew Criswell wrote:

> 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 
                                           ^^^^^^^^^^^^^^
                                           Same thing as ***what***????
> below is obviously wrong
> 
>  > paste(x, cat, sep = "$")
>  >

It's not at all clear what you want to do.  Do you just wish
to create the string ``x$cat''?  This would be done via

	> paste("x","cat",sep="$")

But why?  It's a bad idea to use ``$'' in strings since ``$''
has a special meaning in R (i.e. to refer to components of lists).


				cheers,

					Rolf Turner
					rolf at math.unb.ca




More information about the R-help mailing list