Hello!
So I am handling this problem with some arrays grp1-grp7, I want to write a
loop to avoid tedious work, but I don't know how to transform string to
boor?
For example I used
i=1
paste("grp",i, sep="")
I only got "grp1" instead of grp1, which can't be manipulate using mean() or
other function.
I am not sure if I make myself clear...
THANKS!!!!
Nellie
--
View this message in context: http://r.789695.n4.nabble.com/question-about-string-to-boor-tp3890983p3890983.html
Sent from the R help mailing list archive at Nabble.com.
question about string to boor?
5 messages · David Winsemius, Christoph Molnar, Rolf Turner +1 more
On Oct 10, 2011, at 12:52 PM, song_gpqg wrote:
Hello!
So I am handling this problem with some arrays grp1-grp7, I want to
write a
loop to avoid tedious work, but I don't know how to transform string
to
boor?
For example I used
i=1
paste("grp",i, sep="")
?get
e.g.
get( paste("grp",i, sep="") )
I only got "grp1" instead of grp1, which can't be manipulate using mean() or other function. I am not sure if I make myself clear... THANKS!!!! Nellie -- View this message in context: http://r.789695.n4.nabble.com/question-about-string-to-boor-tp3890983p3890983.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ R-help at r-project.org 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.
David Winsemius, MD West Hartford, CT
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111010/6802f6b4/attachment.pl>
On 11/10/11 08:21, Christoph Molnar wrote:
Hi Nellie,
hope I got you right. I guess you want something like that.
for (i in 1:7) {
oneOfNelliesArray<- eval(parse(text=paste("grp",i, sep="")))
anyFunction(oneOfNelliesArray)
}
Paste() just returns you a string. But you want R to evaluate the
expression. So you have to parse it and tell R to evaluate it.
But using get() is so much simpler and safer.
cheers,
Rolf Turner
Thanks guys, that's a great help. Nellie -- View this message in context: http://r.789695.n4.nabble.com/question-about-string-to-boor-tp3890983p3894996.html Sent from the R help mailing list archive at Nabble.com.