Good morning experts!

situation:

class(myMatrix)="matrix"
class(myMatrix[(1:2),]))="matrix"
class(myMatrix[1,])= "character"

consequences are far reaching as, for instance colnames(myMatrix[(1:2),]) != 
colnames(myMatrix[1,]) or names(myMatrix[(1:2),]) !=  names(myMatrix[1,])

My question: 
1. How can the coercion to character be avoided and the attributes of the
original object myMatrix of class "matrix" been preserved when slicing out
one row of the matrix?
2. Is there a reason why there is a "loss of generality" in that sense that
a matrix of dimension (1xn) is treated differently than a matrix of
dimension (mxn); m,n>1 ? in other words is there a reason why class vector
is needed at all?

Many thanks for your help!
Holger
-- 
View this message in context: 
http://r.789695.n4.nabble.com/class-matrix-lost-when-extracting-a-row-from-matrix-tp2545719p2545719.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.

Reply via email to