Is there any way to force a slice of a matrix to stay a matrix? R
tends to convert a single row of a matrix into a vector.
Example:
z<-matrix (rnorm(20), ncol=5)
zz<-z[1,]
is.matrix(zz) #FALSE
I usually resort to:
zz<-matrix(z[1,], ncol=dim(z)[2], dimnames=list(rownames(z)[1],
colnames(z)))
But that seems horribly kludgy.
Thanks!
-Jim
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.