[R] dim vs length for vectors

Thomas Lumley tlumley at u.washington.edu
Fri Jan 21 19:24:49 CET 2005


On Fri, 21 Jan 2005, Olivia Lau wrote:
> What I was proposing doesn't require a lot of programming.  Just whenever you 
> call dim(), it does length() if the object is a vector and returns it in the 
> format:
>
> R> a <- 1:12
> R> dim(a)
> [1]  12
>

One problem is that there is code using is.null(dim(x)) to distinguish 
vectors from matrices.  This code would break.

 	-thomas




More information about the R-help mailing list