Re: [R] poor rbind performance

2007-07-18 Thread Tony Plate
As Jim points out, building up a data frame by rbinding in a loop can be a slow way to do things in R. Here's an example of how you can easily read data frames into a list: > # Create 3 files > invisible(lapply(1:3, function(i) write.csv(file=paste("tmp",i,".csv",sep=""), data.frame(i=2*i+(

Re: [R] poor rbind performance

2007-07-17 Thread jim holtman
Read the data into a list and then: do.call('rbind', myList) at the end so you do it only once. You are having to reallocate memory each iteration, so no wonder it is slow. On 7/17/07, Aydemir, Zava (FID) <[EMAIL PROTECTED]> wrote: > Hi > > I rbind data frames in a loop in a cumulative way and

[R] poor rbind performance

2007-07-17 Thread Aydemir, Zava \(FID\)
Hi I rbind data frames in a loop in a cumulative way and the performance detriorates very quickly. My code looks like this: for( k in 1:N) { filename <- paste("/tmp/myData_",as.character(k),".txt",sep="") myDataTmp <- read.table(filename,header=TRUE,sep=",") if( k == 1) {