Entering edit mode
I would like to know how to evaluate a character string as a variable
name
in R. Specifically, I need to "compute" the variable name in the
phenoData
slot of an ExpressionSet object.
> varLabels(sample.ExpressionSet)
[1] "sex" "type" "score"
Now I need to retrieve the factors sample.ExpressionSet$sex,
sample.ExpressionSet$type and sample.ExpressionSet$score in turn.
Furthermore, I need to be able to generalize my code so that I can
retrieve
this factor for any phenodata variable in any given ExpressionSet
object.
Clearly I cannot do something like
for (i in c(1:length(varLabels(sample.ExpressionSet)))
{
class_label <- varLabels(sample.ExpresionSet)[i]
class_label_factor <- sample.ExpressionSet$class_label
}
Here class_label is interpreted as a character string by R, but I need
for
it to be evaluated as a variable name. Seems straightforward, but I
couldn't
figure it out...How can I do this? Thanks in advance for any help!
Kavitha
[[alternative HTML version deleted]]