Several ways, two are shown:
> matrix(1:(4*7), 4,7)
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] 1 5 9 13 17 21 25
[2,] 2 6 10 14 18 22 26
[3,] 3 7 11 15 19 23 27
[4,] 4 8 12 16 20 24 28
> mtx <- matrix(1:(4*7), 4,7)
> mtx[-1,]
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] 2 6 10 14 18 22 26
[2,] 3 7 11 15 19 23 27
[3,] 4 8 12 16 20 24 28
> mtx[2:4, ]
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] 2 6 10 14 18 22 26
[2,] 3 7 11 15 19 23 27
[3,] 4 8 12 16 20 24 28
Search terms:
--- at the R prompt
?Extract
?"[" #gets to the same page
--- in other sites:
indexing
--
David Winsemius
On Jan 31, 2009, at 8:25 AM, Rofizah Mohammad wrote:
Hello,
How do I get sub-matrix? Example, I would like to get matrix of size
3x7
from the matrix of size 4x7. Meaning that I try to exclude one row
of the
original matrix.
Thanks
-rofizah-
[[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.
______________________________________________
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.