[R] Managing output
Don MacQueen
macq at llnl.gov
Thu Aug 27 01:35:29 CEST 2009
See minor comment below
-Don
At 8:07 PM +0000 8/26/09, Oliver Bandel wrote:
<- first part of email omitted ->
><
>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
Simpler is
mydat <- numeric(100)
> > 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
>> mydat <- 1
>> mydat[2] <- 33
>> mydat[3] <- -4
>> mydat
>[1] 1 33 -4
>
>
>instead of "mydat[1:100] <- 0"
>use the length of the itemlist as second parameter.
>
>Ciao,
> Oliver
>
>______________________________________________
>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.
--
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062
More information about the R-help
mailing list