[R] cbind in for loops

2010-07-12 Thread jd6688
I have 30 files in the current directories, i would like to perform the cbind(fil1,file2,file3,file4file30) how could i do this in a for loop: such as: file2 - list.files(pattern=.out3$) for (j in file2) { cbind(j)...how to implement cbind here } Thanks.

Re: [R] cbind in for loops

2010-07-12 Thread Joshua Wiley
Hi, Assuming that you have read the files into R, and that their names (in R) are held in some object (e.g., 'file2'), then this works do.call(what = cbind, args = mget(x = file2, envir = .GlobalEnv) Here is a reproducible example: x1 - data.frame(x = 1:10) x2 - data.frame(y = 1:10) file.names

Re: [R] cbind in for loops

2010-07-12 Thread David Winsemius
On Jul 12, 2010, at 2:32 AM, Joshua Wiley wrote: Hi, Assuming that you have read the files into R, and that their names (in R) are held in some object (e.g., 'file2'), then this works do.call(what = cbind, args = mget(x = file2, envir = .GlobalEnv) Here is a reproducible example: x1 -

Re: [R] cbind in for loops

2010-07-12 Thread Henrique Dallazuanna
Try this: do.call(cbind, lapply(dir(pattern = '.out3$'), read.table)) On Mon, Jul 12, 2010 at 1:08 AM, jd6688 jdsignat...@gmail.com wrote: I have 30 files in the current directories, i would like to perform the cbind(fil1,file2,file3,file4file30) how could i do this in a for loop: