[R] Fast nested List->data.frame
Dieter Menne
dieter.menne at menne-biomed.de
Tue Jan 5 08:43:44 CET 2010
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 = 100000
d = replicate(len, list(pH = 3,marker = TRUE,position = "A"),FALSE)
# Data are given as d
# preallocate vectors
pH =rep(0,len)
marker =rep(0,len)
position =rep(0,len)
system.time(
{
for (i in 1:len)
{
d1 = d[[i]]
#Assign to vectors
pH[i] = d1[[1]]
marker[i] = d1[[2]]
position[i] = d1[[3]]
}
# combine vectors
pHAll = data.frame(pH,marker,position)
}
)
--
View this message in context: http://n4.nabble.com/Fast-nested-List-data-frame-tp998871p998871.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list