[R] Quicker way of combining vectors into a data.frame

Marc Schwartz marc_schwartz at comcast.net
Thu Nov 30 18:34:56 CET 2006


Gavin,

One more note, which is that even timing the direct data frame creation
on my system with colnames, again using the same 10 numeric columns, I
get:

> system.time(DF1 <- data.frame(lc.ratio = Col1, Q = Col2, fNupt = Col3,
                                rho.n = Col4, rho.s = Col5, 
                                net.Nimm = Col6, net.Nden = Col7, 
                                CLminN = Col8, CLmaxN = Col9, 
                                CLmaxS = Col10))
[1] 0.012 0.000 0.028 0.000 0.000


> str(DF1)
'data.frame':   4471 obs. of  10 variables:
 $ lc.ratio: num   0.1423  0.1873 -1.8129  0.0255 -1.7650 ...
 $ Q       : num   0.8340 -0.2387 -0.0864 -1.1184 -0.3368 ...
 $ fNupt   : num  -0.1718 -0.0549  1.5194 -1.6127 -1.2019 ...
 $ rho.n   : num  -0.740  0.240  0.522 -1.492  1.003 ...
 $ rho.s   : num  -0.2363 -1.6248 -0.3045  0.0294  0.1240 ...
 $ net.Nimm: num  -0.774  0.947 -1.098  0.809  1.216 ...
 $ net.Nden: num  -0.198 -0.135 -0.300 -0.618 -0.784 ...
 $ CLminN  : num   0.924 -3.265  0.211  0.813  0.262 ...
 $ CLmaxN  : num   0.3212 -0.0502 -0.9978  0.9005 -1.6535 ...
 $ CLmaxS  : num  -0.520  0.278 -0.546 -0.925  1.507 ...




So there is something else going on, either with your code or some other
conflict, unless my assumptions about your data are incorrect.

HTH,

Marc



More information about the R-help mailing list