Skip to content

Dimension of a vector

3 messages · Murray Jorgensen, Gabor Grothendieck, Brian Ripley

#
Consider the following:
[1]  1  2  3  4  5  6  7  8  9 10
NULL
[,1] [,2] [,3] [,4] [,5]
[1,]    1    3    5    7    9
[2,]    2    4    6    8   10
[1] 2 5
[1]  1  2  3  4  5  6  7  8  9 10
[1] 10

Would it not make sense to have dim(A) = length(A) for all vectors?

Murray
#
In R, vectors don't have dimensions, arrays do.
[1] "numeric"
[1] "array"
NULL
[1] 3
On Dec 4, 2007 7:35 PM, <maj at stats.waikato.ac.nz> wrote:
#
On Wed, 5 Dec 2007, maj at stats.waikato.ac.nz wrote:

            
No.  A one-dimensional array and a vector are not the same thing.
There are subtle differences, such as what names() means (see ?names).

That a 1D array and a vector _print_ in the same way does occasionally 
lead to confusion, but then you also cannot tell from your printout that A 
has type "integer" and not "double".