Dear R, I have two small questions confused me recently. Now assume I have a matrix "a", like this,
> a <- matrix(1:6, 2, 3) > a [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6 I sometimes need each row of "a" raised to a different exponent. So I do a trick like this, > a^c(2, 3) [,1] [,2] [,3] [1,] 1 9 25 [2,] 8 64 216 My first question is that if it is possible to do this trick column wise? Just out of curiosity, of course I know there are other ways of doing this. And the second question is why I get such result when I put another element in the exponent part like this, > a^c(2, 3, 4) [,1] [,2] [,3] [1,] 1 81 125 [2,] 8 16 1296 BTW, I have a 64bit R version (2.11) for Linux. Any advice would be appreciated. Feng -- Feng Li Department of Statistics Stockholm University 106 91 Stockholm, Sweden http://feng.li/ [[alternative HTML version deleted]] ______________________________________________ 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.