[R] Matrix manipulation
Tim Calkins
tim.calkins at gmail.com
Tue Oct 23 00:27:03 CEST 2007
use the '-' feature.
>mat <- matrix(rnorm(100), nrow = 10)
#snip the second row
>mat[-2,]
#snip the third column
>mat[,-3]
#snip rows 5 and 7
>mat[-c(5,7),]
cheers
tc
On 10/23/07, yiferic at berkeley.edu <yiferic at berkeley.edu> wrote:
> Hi everyone,
>
> suppose I have a 2D matrix, is there a command to snip out a specific
> row/column and then remerge the remaining columns/rows back into a
> contiguous matrix? I will need to repeat this operation quite a
> bit(reverse selection).
>
> Thanks for any insights you can offer.
>
> Yifei
>
> ______________________________________________
> 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.
>
--
Tim Calkins
0406 753 997
More information about the R-help
mailing list