[R] Referring to an object by a variable containing its name: 6 failures
Timothy Bates
timothy.c.bates at gmail.com
Fri Sep 16 16:09:23 CEST 2011
On 16 Sep 2011, at 1:49 AM, andrewH wrote:
>> I'm trying to make a function that takes column names then
>> using the variable colName, containing the name of
>> the column, to refer to the column itself
rmailbox at justemail.net said
> What am I missing about your inquiry: It seems like x[ , colName ] should work:
I think what is being asked is to treat the value of a variable not as a string (which work fine in your example), but as a variable name
In php you’d use $$ to dereference by name
$whatIwant = 2
$nomdeplume = "whatIwant"
$$nomdeplume
2
I’ve not come across this functionality in R: would be great if it exists
More information about the R-help
mailing list