[R] polynomial expansion in R
Martin Maechler
maechler at stat.math.ethz.ch
Sat Jul 1 17:50:11 CEST 2006
>>>>> "yyan" == yyan liu <zhliur at yahoo.com>
>>>>> on Fri, 30 Jun 2006 21:11:31 -0700 (PDT) writes:
yyan> Hi: I have two vectors of data, x and y and I want to
yyan> get the "polynomial" expansion of (x+y)^p with any
yyan> integer power p in R. Suppose p=2, then I want a
yyan> matrix of five vectors, namely, x y x^2 y^2 x*y. The
yyan> coefficient of the polynomial is not needed. I can
yyan> write it manully if p is small. But I want it in the
yyan> case of p=10 or even bigger, is there any function in
yyan> R can do that automatically for me with certain choice
yyan> of p? Thx a lot!
polym(x,y, degree = p, raw = TRUE)
will probably be pretty close to what you want.
Martin Maechler, ETH Zurich
More information about the R-help
mailing list