[R] empty array

Christophe Genolini cgenolin at u-paris10.fr
Sat Mar 15 17:46:04 CET 2008


John Kane a écrit :
> Will
> mymatrix <- NULL do what you want?
>   
Well, in your code, 'mymatrix' is not a matrix :

a<-array(dim=c(0,0))  # Solution of Gabor Csardi
<0 x 0 matrix>
class(a)
[1] "matrix"
b<-NULL
class(b)
[1] "NULL"

Your definition will probably works in most case, but in S4, the uses of 
type is an important point, so I need to use matrix where I shall use 
matrix, even if it is an empty one.

Christophe

> --- Christophe Genolini <cgenolin at u-paris10.fr> wrote:
>
>   
>> Hi the list
>>
>> Is it possible to create an empty matrix ? I do not
>> mean an matrix with 
>> a single value that is NA (which is not empty) but a
>> real empty one, 
>> with length=0.
>>
>> I do not understand why we have length(numeric()),
>> length(factor()) and 
>> length(character()) to zero, and length(array()) to
>> one... Any rason for 
>> that ?
>>
>> Thanks
>>
>> Christophe
>>
>> ______________________________________________
>> 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.
>>
>>     
>
>
>
>       Be smarter than spam. See how smart SpamGuard is at giving junk email the boot with the All-new Yahoo! Mail.  Click on Options in Mail and switch to New Mail today or register for free at http://mail.yahoo.ca 
>
>



More information about the R-help mailing list