Re: [R] Best way to preallocate numeric NA array?

2009-11-27 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Rob Steele > Sent: Thursday, November 26, 2009 8:03 AM > To: r-h...@stat.math.ethz.ch > Subject: [R] Best way to preallocate numeric NA array? > > These

Re: [R] Best way to preallocate numeric NA array?

2009-11-27 Thread Petr PIKAL
Hi There is one issue which I encountered recently with this type of behaviour, mat<-matrix(NA,5,4) fix(mat) put some number in any cell and close fix mat col1 col2 col3 col4 [1,] NA NA NA NA [2,] NA NA NA NA [3,] NA NA NA NA [4,] NA NA NA NA [5,] NA N

Re: [R] Best way to preallocate numeric NA array?

2009-11-26 Thread Rob Steele
Douglas Bates wrote: > On Thu, Nov 26, 2009 at 10:03 AM, Rob Steele > wrote: >> These are the ways that occur to me. >> >> ## This produces a logical vector, which will get converted to a numeric >> ## vector the first time a number is assigned to it. That seems >> ## wasteful. >> x <- rep(NA, n)

Re: [R] Best way to preallocate numeric NA array?

2009-11-26 Thread Rob Steele
Douglas Bates wrote: > On Thu, Nov 26, 2009 at 10:03 AM, Rob Steele > wrote: >> These are the ways that occur to me. >> >> ## This produces a logical vector, which will get converted to a numeric >> ## vector the first time a number is assigned to it. That seems >> ## wasteful. >> x <- rep(NA, n)

Re: [R] Best way to preallocate numeric NA array?

2009-11-26 Thread Henrique Dallazuanna
Or best: rep(NA_real_, 10) On Thu, Nov 26, 2009 at 2:31 PM, Henrique Dallazuanna wrote: > You can try this also: > > rep(NA_integer_, 10) > > On Thu, Nov 26, 2009 at 2:03 PM, Rob Steele > wrote: >> These are the ways that occur to me. >> >> ## This produces a logical vector, which will get conv

Re: [R] Best way to preallocate numeric NA array?

2009-11-26 Thread Henrique Dallazuanna
You can try this also: rep(NA_integer_, 10) On Thu, Nov 26, 2009 at 2:03 PM, Rob Steele wrote: > These are the ways that occur to me. > > ## This produces a logical vector, which will get converted to a numeric > ## vector the first time a number is assigned to it.  That seems > ## wasteful. > x

Re: [R] Best way to preallocate numeric NA array?

2009-11-26 Thread Douglas Bates
On Thu, Nov 26, 2009 at 10:03 AM, Rob Steele wrote: > These are the ways that occur to me. > > ## This produces a logical vector, which will get converted to a numeric > ## vector the first time a number is assigned to it.  That seems > ## wasteful. > x <- rep(NA, n) > > ## This does the conversio

[R] Best way to preallocate numeric NA array?

2009-11-26 Thread Rob Steele
These are the ways that occur to me. ## This produces a logical vector, which will get converted to a numeric ## vector the first time a number is assigned to it. That seems ## wasteful. x <- rep(NA, n) ## This does the conversion ahead of time but it's still creating a ## logical vector first,