[R] delete a row in a matrix
Julian Burgos
jmburgos at u.washington.edu
Mon Nov 19 23:23:11 CET 2007
Something like this?
> a=matrix(1:9, ncol=3)
> print(a)
[,1] [,2] [,3]
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9
> a=a[-2,]
> print(a)
[,1] [,2] [,3]
[1,] 1 4 7
[2,] 3 6 9
You can use negative numbers to reference rows and/or columns, and
you'll get everything except the rows/columns referenced.
Julian
Barb, Jennifer (NIH/CIT) [E] wrote:
> Can anyone tell me how to delete a row in a matrix? I have searched
> around and couldn't find a straightforward way to do this.
>
> Thanks, any help will be greatly appreciated.
>
> Jennifer
>
>
>
>
>
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list