Re: [R] Help in creating a matrix

2012-04-12 Thread arunkumar1111
The formula is created sepearately and data is created for the formula and then use the modelling lm - Thanks in Advance Arun -- View this message in context: http://r.789695.n4.nabble.com/Help-in-creating-a-matrix-tp4551532p4551967.html Sent from the R help mailing list archive at N

Re: [R] Help in creating a matrix

2012-04-12 Thread S Ellison
>I have dataset with n variables, say n =3 x y z >the formula should be form = x+y+z+x*x +x*y+x*z +y*y + y*z+z*z >my code has to for loop >Is there any way to reduce two loops > for (i in 1:n) > { > for (j in i:n) > { >dat= cbind(dat,dat[,i]*dat[,j]) > } > } Yes; use

[R] Help in creating a matrix

2012-04-12 Thread arunkumar1111
Hi I have dataset with n variables, say n =3 x y z the formula should be form = x+y+z+x*x +x*y+x*z +y*y + y*z+z*z my code has to for loop Is there any way to reduce two loops for (i in 1:n) { for (j in i:n) { dat= cbind(dat,dat[,i]*dat[,j]) } } ---