[R] question about matrix
Douglas Bates
bates at stat.wisc.edu
Mon Feb 16 21:20:08 CET 2004
Cynthia He <dingdong1205 at yahoo.com> writes:
> How to write this matrix in R? The "^" sign is a power symbol.
>
> Thanks a lot!
>
>
> 0^1 0^2 ......... 0^n
> 1^1 1^2 ......... 1^n
> 2^1 2^2 ......... 2^n
> ................................
> ................................
> q^1 q^2 ......... q^n
Use the outer product function, as in
> outer(0:5, 1:4, "^")
[,1] [,2] [,3] [,4]
[1,] 0 0 0 0
[2,] 1 1 1 1
[3,] 2 4 8 16
[4,] 3 9 27 81
[5,] 4 16 64 256
[6,] 5 25 125 625
More information about the R-help
mailing list