[R] Allocation of memory to a data frame

santosh santosh.srinivas at gmail.com
Wed Apr 20 09:46:50 CEST 2011

Hello gRoup,

A while back I was advised that overallocating an object and filling
it up is better than rbind.

I am trying to optimize some code. I have the following object (empty
which I know in advance).
Is there an easy to create an empty data frame with 100,000 empty rows
based on the structure below?

> dput(d)
structure(list(A = character(0), B = character(0), C = numeric(0),
    D = character(0), E = character(0), F = character(0), G =
    H = structure(numeric(0), class = "Date"), I = numeric(0),
    J = integer(0)), .Names = c("A", "B", "C", "D", "E", "F",
"G", "H", "I", "J"), row.names = integer(0), class = "data.frame")

I can use dataFrame in R.utils and do it explicitly but wondering if
there an easier way since I have the structure with me.

Thank you.

More information about the R-help mailing list