[R] rbind and data.frame

Emmanuel Paradis paradis at isem.univ-montp2.fr
Fri Dec 7 15:08:24 CET 2001


G=F6ran,

At 11:04 07/12/01 +0100, G=F6ran Brostr=F6m wrote:
>On Wed, 5 Dec 2001, G=F6ran Brostr=F6m wrote:
>
>[...]
>=20
>> My real problem is how to create a data frame in a sequentially growing
>> manner, when I know the final size (no of cases). I want to avoid to
>> call 'rbind' many times, and instead create an 'empty' data frame in
>> one call, and then fill it. Are there better ways of doing this?
>
>Got no answer to this one, so I provide one myself:
>
>The answer is: Yes, definitely. I did this, with pure  R  code, and=20
>created a new data frame with around 58000 records. It took 7 hours to=20
>run. I then did it with compiled code (Fortran), and that made a slight
>difference:  It took 4.8 seconds(!).
>
>G=F6ran

I seem to remember that R is not very efficient at creating/manipulating
large data frames. Did you consider doing it with a matrix with 58000 rows?
In that case, of course, all your columns *must* be of the same mode.

Emmanuel Paradis
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list