Matrices are not made of paper! :)  If you index a matrix with negative 
numbers, you'll get back that matrix minus that column or row.

A quick example:

 >a<-matrix(c(1:9),ncol=3)  # Create a sample matrix
 >a                        # Display it
      [,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9

 >a[,2] # Get the second column
[1] 4 5 6

 >a[,-2] # Everything except the second column

      [,1] [,2]
[1,]    1    7
[2,]    2    8
[3,]    3    9

Julian



[EMAIL PROTECTED] 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@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.

Reply via email to