Hi,
I've got a quick question about what happens when indexing into matrices
with a single column. I was wondering if anyone can help ...
 
For example:
> x <- matrix(1:10)

> y <- cbind(x,x)

> x[4:6,]

[1] 4 5 6

> y[4:6,]

   [,1] [,2]

[1,] 4 4

[2,] 5 5

[3,] 6 6

> class(x[4:6,])

[1] "integer"

> class(y[4:6,])

[1] "matrix"

It seems that R is returning the results of indexing into a matrix with
one column as a vector rather than a matrix?

Does anyone have a good way of preventing this from happening?

cheers,

crispin
 
--------------------------------------------------------

 
This email is confidential and intended solely for the use o...{{dropped}}

______________________________________________
R-help@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

Reply via email to