[R] including a variable in another variable name

Benilton Carvalho bcarvalh at jhsph.edu
Wed Apr 2 22:29:08 CEST 2008


?assign
b

On Apr 2, 2008, at 4:26 PM, Georg Ehret wrote:
> Dear R community,    I wish to include a variable (e.g. slice of "a"  
> below)
> in another variable's name. My objective would be to get a variable- 
> name
> "data_A" and so on. How can I do this?
>
>> a<-LETTERS[1:25]
>> a
> [1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P"  
> "Q" "R"
> "S" "T" "U" "V" "W" "X" "Y"
>> paste("data_",a[1])<-c(1,2,3)
> Error in paste("data", a[1]) <- c(1, 2, 3) :
>  target of assignment expands to non-language object
>
>
>
> Thank you and wishing you an excellent day!
> Georg.
> **********************
> Georg Ehret
> Johns Hopkins
> Baltimore, MD
> USA
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list