[R] to creates an array

Jim Lemon jim at bitwrit.com.au
Fri Jul 3 11:33:31 CEST 2009


Barbara.Rogo at uniroma1.it wrote:
>
>> Is there a command as "mat.or.vec(nr,nc)" to create an array that I 
>> must calculate with more cicle? 
Hi Barbara,
The approach that I usually use is something like this:

new.matrix<-matrix(NA,nrow=3,ncol=3)

This creates a 3x3 matrix named "new.matrix" that is filled with NAs. 
You can then replace the elements of the array with useful values 
knowing that any value not replaced will remain NA.

Jim




More information about the R-help mailing list