[R] Allocation of memory to a data frame

Uwe Ligges ligges at statistik.tu-dortmund.de
Wed Apr 20 10:27:00 CEST 2011



On 20.04.2011 09:46, santosh wrote:
> 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 =
> 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")


Replace the zeros by your number of rows?

Uwe Ligges



> 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.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list