Dear all, assume I have a matrix with just 1 row. Now suppose I want to
fetch 1st few rows from that matrix, however resulting object becomes
vector. Here is 1 such example:

 

> matrix(1:5, 1)

     [,1] [,2] [,3] [,4] [,5]

[1,]    1    2    3    4    5

> 

> matrix(1:5, 1)[,-1]

[1] 2 3 4 5

 

Can somebody point me how to keep resulting object as matrix with same row?
Ofcourse I again make legitimate matrix with something like as.matrix()
function. However I believe there must be some more directly way with
indexing in some better way!

 

Thanks,


        [[alternative HTML version deleted]]

______________________________________________
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