Re: [R] empty array

From: Gabor Csardi <csardi_at_rmki.kfki.hu>
Date: Sat, 15 Mar 2008 16:42:13 +0100

On Sat, Mar 15, 2008 at 04:33:32PM +0100, Christophe Genolini 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.

Sure:

> matrix(nrow=0, ncol=5)

     [,1] [,2] [,3] [,4] [,5]
> a <- array( dim=c(5,4,0) )
> dim(a)

[1] 5 4 0
> length(a)

[1] 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 ?

That i don't know, maybe someone else does.

G.

> 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.

-- 
Csardi Gabor <csardi_at_rmki.kfki.hu>    UNIL DGM

______________________________________________
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.
Received on Sat 15 Mar 2008 - 15:46:02 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 15 Mar 2008 - 16:30:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive