[R] How to define new matrix based on an elementary row operation in a single step?

Cuckovic Paik cuckovic.paik at gmail.com
Sat Aug 28 06:29:08 CEST 2010


Thanks for respose. 

you still used two steps to get the new matrix tst2: 
step 1: tst2 = tst
step 2: perform the row operation in tst2.

Can you do this in a single step?


A similar example: 
> tst
     [,1] [,2] [,3] [,4]
[1,]    1    5    9   13
[2,]    2    6   10   14
[3,]    3    7   11   15
[4,]    4    8   12   16
# I define a new matrix by deleting the first row and the first column of
matrix tst using following single step:
> New.tst=tst[-1,-1]
> New.tst
     [,1] [,2] [,3]
[1,]    6   10   14
[2,]    7   11   15
[3,]    8   12   16
# the original matrix tst is still .
> tst
     [,1] [,2] [,3] [,4]
[1,]    1    5    9   13
[2,]    2    6   10   14
[3,]    3    7   11   15
[4,]    4    8   12   16




-- 
View this message in context: http://r.789695.n4.nabble.com/How-to-define-new-matrix-based-on-an-elementary-row-operation-in-a-single-step-tp2341768p2344456.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list