[R] convert strings to object names: SUMMARY

Denis Kazakiewicz
2012-05-04T08:06:44Z

Hello to R people
This is not a question. Just found a beautiful summary dated back in
2004. Hope this will be useful for your work
Thanks to Gudrun Jonasdottir <gudrunj_at_math.su.se
<mailto:gudrunj_at_math.su.se?Subject=Re:%20[R]%20convert%20strings%20to%20object%20names:%20SUMMARY>>

In summary: The quickest way to convert a string to an object name,
seems to be by using get(dat), but it seems to work equally well if you
use any of

eval(parse(text=dat))
do.call("print", list(as.name(dat)))
eval(substitute(print(x), list(x=as.name(dat)))) assign("dat",
get(paste("dat", no, sep="")))

And actually my modest addition: what if you want to save a file using a
string as an object name.
Here strname is some string

save(list=strname, file=paste(strname,".Rdata",sep="")

Don't forget to put that list= in front of strname
Denis

	[[alternative HTML version deleted]]