On Mar 24, 2010, at 9:25 AM, Tal Galili wrote:

Try:

for (i in 1:4) {
Data <- eval(parse(text =  paste("data",i,sep="")))
...
..
}


(and if there are other solutions - I would love to know)

Well, it's not actually a solution since the first three fetched values would have been overwritten.

Instead:

 Data <- list()
 for (i in 1:4) {
       Data[[i]] <- eval(parse(text =  paste("data",i,sep=""))) }



----------------Contact
Details:-------------------------------------------------------
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
----------------------------------------------------------------------------------------------




2010/3/24 "Biedermann, Jürgen" <juergen.biederm...@charite.de>

Hi there,

I have the following problem

Four data frames exist:

data1
data2
data3
data4

Now I want to write a loop and temporarily store the data1, data2, data3,
data4 in a variable called data.
I tried the following...

for (i in 1:4) {
Data <- paste("data",i,sep="")
...
..
}


but it doesn't function. I think the problem is the definition of the mode
of the pasted variable.

Could anyone help me?
Thanks

Greetings
Jürgen

______________________________________________
R-help@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.


        [[alternative HTML version deleted]]

______________________________________________
R-help@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

______________________________________________
R-help@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.

Reply via email to