[R] save output of loop

2012-02-14 Thread uday
I have some data files e.g 100 . and after for loop I would like to save all data in one single data frame file_s - list.files(path = ., pattern = v2.0.2.txt, all.files = FALSE, full.names = FALSE, recursive = FALSE, ignore.case = FALSE) for (i in 1:100){

Re: [R] save output of loop

2012-02-14 Thread jim holtman
try this: file_s - list.files(path = ., pattern = v2.0.2.txt, all.files = FALSE, full.names = FALSE, recursive = FALSE, ignore.case = FALSE) result - do.call(rbind, lapply(file_s, function(.file){ data - read.table(.file, header=TRUE) data.frame(lat =

Re: [R] save output of loop

2012-02-14 Thread johnmark
The short answer to your question is *don't* concatenate the values in the row, then attempt to /rbind()/ them incrementally to a data.frame. Instead build each column separately inside the loop, then /cbind() (data.frame()/ does an implicit/ cbind()/ ) them together at the end. Something like

Re: [R] save output of loop

2012-02-14 Thread uday
Hi it works fine thanks -- View this message in context: http://r.789695.n4.nabble.com/save-output-of-loop-tp4386599p4387806.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list

Re: [R] save output of loop

2012-02-14 Thread uday
The dimensions of variables are unknown , they changes to every file. -- View this message in context: http://r.789695.n4.nabble.com/save-output-of-loop-tp4386599p4387804.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] save in for loop

2010-06-04 Thread Joris Meys
On a side note: On Thu, May 20, 2010 at 9:43 AM, Ivan Calandra ivan.calan...@uni-hamburg.de wrote: Thanks to all of you for your answers! ... Tao, I don't understand why you have backslashes before file and after .rda. I guess it's something about regular expression, but I'm still very new

Re: [R] save in for loop

2010-05-20 Thread Ivan Calandra
, temp) save(list=c(filename), file=paste(filename, .rda, sep=)) } -Peter Ehlers - Original Message From: Ivan Calandraivan.calan...@uni-hamburg.de To: r-help@r-project.org Sent: Wed, May 19, 2010 7:56:44 AM Subject: [R] save in for loop Dear users, My problem concerns

Re: [R] save in for loop

2010-05-20 Thread Ivan Calandra
To: r-help@r-project.org mailto:r-help@r-project.org Sent: Wed, May 19, 2010 7:56:44 AM Subject: [R] save in for loop Dear users, My problem concerns save() within a for loop. Here is my code: for (i in 1:4) { temp- data.frame(a=(i

[R] save in for loop

2010-05-19 Thread Ivan Calandra
Dear users, My problem concerns save() within a for loop. Here is my code: for (i in 1:4) { temp - data.frame(a=(i+1):(i+10), b=LETTERS[(i+1):(i+10)]) filename - paste(file, i, sep=) assign(filename, temp) save(filename, file=paste(filename, .rda, sep=)) } As you can see, save() doesn't

Re: [R] save in for loop

2010-05-19 Thread Shi, Tao
Ivan, Try this: eval(parse(text=paste(save(file, i, , file=\file, i, .RData\), sep=))) ...Tao - Original Message From: Ivan Calandra ivan.calan...@uni-hamburg.de To: r-help@r-project.org Sent: Wed, May 19, 2010 7:56:44 AM Subject: [R] save in for loop Dear users, My problem

Re: [R] save in for loop

2010-05-19 Thread Jorge Ivan Velez
Hi Ivan, How about this? i - 1:4 sapply(i, function(i){ x - data.frame(a=(i+1):(i+10), b=LETTERS[(i+1):(i+10)]) save(x, file = paste(file, i, .rda, sep=)) } ) HTH, Jorge On Wed, May 19, 2010 at 10:56 AM, Ivan Calandra wrote: Dear users, My problem concerns save() within a for loop.

Re: [R] save in for loop

2010-05-19 Thread Peter Ehlers
(filename, temp) save(list=c(filename), file=paste(filename, .rda, sep=)) } -Peter Ehlers - Original Message From: Ivan Calandraivan.calan...@uni-hamburg.de To: r-help@r-project.org Sent: Wed, May 19, 2010 7:56:44 AM Subject: [R] save in for loop Dear users, My problem concerns save