[R] dim vs length for vectors

Uwe Ligges ligges at statistik.uni-dortmund.de
Fri Jan 21 12:55:40 CET 2005


Arne Henningsen wrote:

> On Friday 21 January 2005 06:35, Gabor Grothendieck wrote:
> 
>>In R, vectors are not arrays:
>>
>>R> v <- 1:4
>>R> dim(v)
>>NULL
>>R> is.array(v)
>>[1] FALSE
>>
>>R> a <- array(1:4)
>>R> dim(a)
>>[1] 4
>>R> is.array(a)
>>[1] TRUE
> 
> 
> Is this a feature which is useful in some applications?
> IMHO the difference between vectors and 1-dimensional arrays is really 
> annoying and I had already several bugs in my code, because I mixed these up.
> Is it possible in future versions of R that R does not differentiate between 
> vectors and 1-dimensional arrays (e.g. by treating all vectors as 
> 1-dimensional arrays)?

No, that would break huge amounts of code!

See ?"[" and learn how to use its argument "drop".

Uwe Ligges


> Arne
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list