> -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
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
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)
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)
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
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
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
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,
8 matches
Mail list logo