[R] How to properly use a generated test string as a name?
David Winsemius
dwinsemius at comcast.net
Wed Feb 9 20:37:54 CET 2011
On Feb 9, 2011, at 2:20 PM, Erik Iverson wrote:
>
>
> Mark Knecht wrote:
>> Title asks it all.
>> Thanks in advance,
>> Mark
>> a = 1:5
>> b1 = 2:6
>> Z = data.frame(a,b1)
>> Z
>> Z$b1
>> count = 1
>> MyName = paste("b",count,sep="")
>> MyName
>> Z$MyName
>
> Z[[MyName]]
Also:
http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-turn-a-string-into-a-variable_003f
(And Iverson's solution is the "without any of this messing around"
approach.)
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list