On 28-Aug-10 13:15:47, Cuckovic Paik wrote: > Thank all help help. Ted's intuitive single step definition > is what I want. > I try to teach elementary Linear Algebra using R to manupilate > matrices. > Since my students have no programming experience at all, any fancy and > muliple step definition in matrix row operation will confuse them. > Again, I appreciate the suggestions from all of you! > --
Just to avoid any misunderstanding: My contribution was an explanatory comment to Gabor's solution. It was Gabor who gave the solution! But, while I am at it, if you are teaching elementary Linear Algebra and matrix manipulation, note that the desired result (rows 1, 2 & 4 of A, with row 3 = 2*(row 1 of A) + (row 3 of A)) can be obtained using a matrix product: 1 0 0 0 %*% 1 5 9 13 0 1 0 0 2 6 10 14 2 0 1 0 3 7 11 15 0 0 0 1 4 8 12 16 i.e. (in R): (diag(nrow(A)) + c(0,0,2,0, 0,0,0,0, 0,0,0,0, 0,0,0,0))%*%A # [,1] [,2] [,3] [,4] # [1,] 1 5 9 13 # [2,] 2 6 10 14 # [3,] 5 17 29 41 # [4,] 4 8 12 16 (as before). Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <ted.hard...@manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 28-Aug-10 Time: 15:12:03 ------------------------------ XFMail ------------------------------ ______________________________________________ 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.