Re: [R] Filling out a data frame row by row.... slow!

2012-02-15 Thread ilai
First, in R there is no need to declare the dimensions of your objects before they are populated so couldn't you reduce some run time by not going through the double data.frame step ? > df<- data.frame() > df data frame with 0 columns and 0 rows > for(i in 1:100) for(j in 1:3) df[i,j]<- runif(1) >

Re: [R] Filling out a data frame row by row.... slow!

2012-02-15 Thread William Dunlap
Row) for (j in colNums) { length(data[[j]]) <- curSize } } for(j in colNums) { data[[j]][i] <- i + j/10 } } names(data) <- colNames data.frame(data) } Bill Dunlap Spotfire, TIBCO Software wdunlap tibc

Re: [R] Filling out a data frame row by row.... slow!

2012-02-15 Thread Peter Meilstrup
On Tue, Feb 14, 2012 at 2:31 PM, William Dunlap wrote: > If you must repeatedly append rows to a data.frame, > try making the dataset you are filling in a bunch > of independent vectors, perhaps in a new environment > to keep things organized. One complication is I don't know the names of the c

Re: [R] Filling out a data frame row by row.... slow!

2012-02-14 Thread William Dunlap
d 52.193.81 54.69 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Peter Meilstrup > Sent: Tuesday, February 14, 2012 1:47 PM > To: r-help@r-project.

[R] Filling out a data frame row by row.... slow!

2012-02-14 Thread Peter Meilstrup
I'm reading a file and using the file to populate a data frame. The way the file is laid out, I need to fill in the data frame one row at a time. When I start reading my file, I don't know how many rows I will need. It's on the order of a million. Being mindful of the time expense of reallocation