If we have the following matrix: Mat<-matrix(1:9, byrow=TRUE, nrow=3) Mat
[,1] [,2] [,3] [1,] 1 2 3 [2,] 4 5 6 [3,] 7 8 9 I would like to have each row multiplied by a different number. So I would like row 1 multiplied by 3, row2 by 1 and row3 by 0.5 Which would give: [,1] [,2] [,3] [1,] 3 6 9 [2,] 4 5 6 [3,] 3.5 4 4.5 Whatever I try, I always obtain [,1] [,2] [,3] [1,] 3 2 1.5 [2,] 12 5 3.0 [3,] 21 8 4.5 Which corresponds to the columns multiplied by the factors Could anyone help we to get the proper result ? Best, Anne-Christine da Silva ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.