[R] Adding terms to a function

2006-12-06 Thread Brooke LaFlamme
Hi all, I am running R version 2.4.0 on Windows XP. I am new and have the following question: I have a dataset of columns named x1, x2, x3...xn. I would like to write a linear regression using lm that looks like this: lm(y~x1+x2+x3+...+xn) If I try to use the following code, I only get the

Re: [R] Adding terms to a function

2006-12-06 Thread Simon Blomberg
How about this: form - formula(paste(y ~, paste(x, 1:n, sep=, collapse= + ))) model - lm(form) HTH, Simon. Brooke LaFlamme wrote: Hi all, I am running R version 2.4.0 on Windows XP. I am new and have the following question: I have a dataset of columns named x1, x2, x3...xn. I would

Re: [R] Adding terms to a function

2006-12-06 Thread Gabor Grothendieck
Using the builtin anscombe data set try this where we note that the first 4 columns are x1, ..., x4 and the fifth column is y1. for(i in 1:4) print(coef(lm(y1 ~., anscombe[c(1:i, 5)]))) On 12/6/06, Brooke LaFlamme [EMAIL PROTECTED] wrote: Hi all, I am running R version 2.4.0 on Windows