[R] assigning values to parameters, based on different names

Jannis bt_jannis at yahoo.de
Tue Dec 1 13:45:18 CET 2009


Dear R help community,


I have tumbleled across some problem quite often and could not find a
solution for it (or was not able to google the right terms).

I am wondering whether there is a way to tell R to assign a value of
parameter X to parameter B while the actual name of parameter X is given
by parameter C. Like this:



C<-"name of parameter X"

B<- parameter X which has the name == C


In that way I can easily change the value of  C and then assign the
values of different parameters to B, depending on which name I entered
and saved as parameter C, which would help me dealing with automatic
loops a lot!

Like this:


for (i in 1:3)
{
   C<-c("name1","name2","name3")[i]
   B<-'parameter with name C'
}

Appreciate any suggestions!

Best
Jannis

P.S. And thanks to all for the amazing answers posted to r-help that
already helped me so many times!




More information about the R-help mailing list