Re: [R] polynomial expansion in R

From: Martin Maechler <>
Date: Sun 02 Jul 2006 - 01:50:11 EST

>>>>> "yyan" == yyan liu <>
>>>>> 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 mailing list PLEASE do read the posting guide! Received on Sun Jul 02 01:57:36 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sun 02 Jul 2006 - 04:13:17 EST.

Mailing list information is available at Please read the posting guide before posting to the list.