Skip to content

Allocation of memory to a data frame

2 messages · Santosh Srinivas, Uwe Ligges

#
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?
structure(list(A = character(0), B = character(0), C = numeric(0),
    D = character(0), E = character(0), F = character(0), G =
character(0),
    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.
#
On 20.04.2011 09:46, santosh wrote:
Replace the zeros by your number of rows?

Uwe Ligges