[R] Managing output

Oliver Bandel oliver at first.in-berlin.de
Wed Aug 26 22:14:06 CEST 2009


Oliver Bandel <oliver <at> first.in-berlin.de> writes:
[...]
> For many entries, it would be faster, if you just allocate
> the array that should be written, by just writing 0 into it,
> or empty strings or something like this...
> > mydat[1:100] <- 0
> > mydat
>   [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>  [38] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>  [75] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[...]


Maybe better combine the pre-allocation with one of the apply-functions...
This would be even faster.

Ciao,
   Oliver




More information about the R-help mailing list