This is probably easy to do, but I could not find a solution.
Say I have a serie of variables : variable1, variable2 ...
I would like to use another variable/list like X<-c("variable1", variable2"...) to call one of the variable (variable1, variable2...) in a function.
Something like : plot(X[1], Y) where 'X[1]' is interpreted as 'variable1'.
Any suggestion ?
Thank you
Guillaume
----- Edit after the first anwsers --
Well the get() function was what I needed. I had tried it before, but could not get what I wanted. I does work now.
Thanks jlhoward and Ananda Mahto for your help.
There are some more explanations for future (potential) readers:
With myData, a dataframe with 3 columns (Value1, Value2, Y)
I can do :
plot(Value1~Y, data=myData)
or
plot(Value2~Y, data=myData)
now if I have a vector such as
myList<-c("Value1", "Value2")
I can do :
i=1
plot(get(myList[i])~Y, data=myData)
or
i=2
plot(get(myList[i])~Y, data=myData)
anymore comments / suggestions welcome
list. You might wantget, but I would discourage you to use it.applyfamily (likelapplyorsapply). Can you provide a minimal example of what you want to do and what you've tried.