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

David Winsemius dwinsemius at comcast.net
Sat Aug 28 06:50:56 CEST 2010


On Aug 28, 2010, at 12:29 AM, Cuckovic Paik wrote:

>
> Thanks for respose.
>
> you still used two steps to get the new matrix tst2:

For Pete"s sake! Can't you see that I didn't _need_ to use tst2. The  
same operations would have worked on tst. I was just using tst2  
because I wanted to be able to restore to the original site.

> step 1: tst2 = tst
> step 2: perform the row operation in tst2.
>
> Can you do this in a single step?

Try it yourself, why not?

-- 
David
>
>
> 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.
>
> ______________________________________________
> 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