See ?get and ?assign On Mon, Feb 22, 2010 at 4:49 PM, Anthony Damico <[email protected]> wrote: > Is there any way to get the last line of this code to double the contents of > a and b without naming them directly? > > #create variables a and b > a<-5 > b<-10 > > #store variable names a and b in variables c and d > c<-"a" > d<-"b" > > e<-c(c,d) > > #loop through both variables > for (i in e){ > > #print the numbers five and ten using only the variables c and d > #this line works fine > print(eval(parse(text=i)))*2 > > #re-assign variables a and b using only variables c and d > #this line does not work - > parse(text=i) <- eval(parse(text=i))*2 > } > > [[alternative HTML version deleted]] > > ______________________________________________ > [email protected] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

