Skip to content
Back to formatted view

Raw Message

Message-ID: <1262677424043-998871.post@n4.nabble.com>
Date: 2010-01-05T07:43:44Z
From: Dieter Menne
Subject: Fast nested List->data.frame

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.