Re: [R] multiply each row in a matrix with the help of the for loop

2012-11-13 Thread D. Rizopoulos
g] on behalf of arun [smartpink...@yahoo.com] Sent: Tuesday, November 13, 2012 15:25 To: Haris Rhrlp Cc: R help Subject: Re: [R] multiply each row in a matrix with the help of the for loop HI, May be this helps: list1<-lapply(lapply(1:3,function(i) {aa[1:i,,i]<-a[1:i,]*-1 return(aa[,,i])})

Re: [R] multiply each row in a matrix with the help of the for loop

2012-11-13 Thread arun
"R-help@r-project.org" Cc: Sent: Tuesday, November 13, 2012 7:41 AM Subject: [R] multiply each row in a matrix with the help of the for loop Dear R users, I have this program aa<-array(rep(0,27),dim=c(3,3,3)) a<-matrix(rep(1,9),ncol=3) n<-0 for (i in 1:3) {            a[

[R] multiply each row in a matrix with the help of the for loop

2012-11-13 Thread Haris Rhrlp
Dear R users, I have this program aa<-array(rep(0,27),dim=c(3,3,3)) a<-matrix(rep(1,9),ncol=3) n<-0 for (i in 1:3) {            a[i,]<-a[i,]*(-1)       n<-n+1       aa[,,n]<-a[i,] } but i real want to multiply each row  with -1 according to for loop and after that to put it in the array.  I w