Skip to content
Prev 31027 / 63421 Next

x <- 1:2; dim(x) <- 2? A vector or not?

Ran into the follow intermediate case in an external package (w/
recent R v2.8.1 patched and R v2.9.0 devel):
[1] 2
[1] 1 2
int [, 1:2] 1 2
[1] 2
[1] NA
[1] FALSE
[1] FALSE
[1] TRUE
[1] 1
Error in x[, 1] : incorrect number of dimensions
Error in x[1, ] : incorrect number of dimensions

Is str() treating single-dimension arrays incorrectly?

What does it mean to have a single dimension this way?  Should it
equal a vector?  I am aware of "is.vector returns FALSE if x has any
attributes except names".

/Henrik