Re: [R] Fast nested List->data.frame

2010-01-05 Thread Dieter Menne
This is better by a factor of 4: len = 10 d = replicate(len, list(pH = 3,marker = TRUE,position = "A"),FALSE) system.time( { pHAll = data.frame( pH = unlist(lapply(d,"[[",1)), pH = unlist(lapply(d,"[[",2)), pH = unlist(lapply(d,"[[",3))) } ) Dieter -- View this messag

Re: [R] Fast nested List->data.frame

2010-01-05 Thread Dieter Menne
Greg Hirson wrote: > > I'd approach this by first making a matrix, then converting to a data > frame with appropriate types. Well, I knew that matrixes are faster for numerics, but I also knew that the required conversion to character would be a show-stopper. My second wisdom was bogus. Your

Re: [R] Fast nested List->data.frame

2010-01-05 Thread Greg Hirson
The as.numeric(d.df$pH) should have been an as.numeric(as.character(d.df$pH)). Sorry for the confusion. Greg On 1/5/10 12:33 AM, Greg Hirson wrote: > Dieter, > > I'd approach this by first making a matrix, then converting to a data > frame with appropriate types. I'm sure there is a way to do

Re: [R] Fast nested List->data.frame

2010-01-05 Thread Greg Hirson
Dieter, I'd approach this by first making a matrix, then converting to a data frame with appropriate types. I'm sure there is a way to do it with structure in one step. Operations on matrices are usually faster than on dataframes. len <- 10 d <- replicate(len, list(pH = 3, marker = TRUE

[R] Fast nested List->data.frame

2010-01-04 Thread Dieter Menne
I have very large data sets given in a format similar to d below. Converting these to a data frame is a bottleneck in my application. My fastest version is given below, but it look clumsy to me. Any ideas? Dieter # --- len = 10 d = replicate(len, list(pH = 3,marker = TRU