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!
Karl Ove Hufthammer
2009-Dec-01 12:50 UTC
[R] assigning values to parameters, based on different names
On Tue, 01 Dec 2009 12:45:18 +0000 Jannis <bt_jannis at yahoo.de> wrote:> 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:Yes. See ?get. -- Karl Ove Hufthammer