Re: [R] lm with an arbitrary number of terms

2003-04-03 Thread Roger Peng
You need to paste() together a formula. There's an example in ?formula. Try, n - 10 rhs - paste(x, 1:n, collapse = +, sep = ) lhs - y ~ f - as.formula(paste(lhs, rhs)) Then pass `f' into lm(). -roger ___ UCLA Department of Statistics [EMAIL PROTECTED]

RE: [R] lm with an arbitrary number of terms

2003-04-03 Thread Bill . Venables
PROTECTED] Sent: Thursday, April 03, 2003 2:50 AM To: [EMAIL PROTECTED] Subject: [R] lm with an arbitrary number of terms Hello folks, Any ideas how to do this? data.frame is a data frame with column names x1,...,xn y is a response variable of length dim(data.frame)[1] I want to write

RE: [R] lm with an arbitrary number of terms

2003-04-03 Thread Darryl
How about the following? lm(as.formula(paste(y~,paste(names(data.frame), collapse=+),sep=),cbind(data.frame,y)) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Richard Nixon Sent: 02 April 2003 19:50 To: [EMAIL PROTECTED] Subject: [R] lm with an arbitrary

Re: [R] lm with an arbitrary number of terms

2003-04-03 Thread Richard Nixon
Thanks to James Holtman, Matt Wiener, Douglas Bates, Spencer Graves, John Fox, Roger Peng, Bill Venable, Darryl Greig, Vadim Ogranovich and Peter Dalgaard There are several ways to tackel this problem, and one easy one which I missed :-)

[R] lm with an arbitrary number of terms

2003-04-02 Thread Richard Nixon
Hello folks, Any ideas how to do this? data.frame is a data frame with column names x1,...,xn y is a response variable of length dim(data.frame)[1] I want to write a function function(y, data.frame){ lm(y~x1+...+xn) } This would be easy if n was always the same. If n is arbitrary how

Re: [R] lm with an arbitrary number of terms

2003-04-02 Thread Spencer Graves
The following might work: mdl - paste(y~, paste(names(data.frame), collapse=+)) lm(mdl, ...) If y = y is a column of your data.frame, you can delete it be selecting names(data.frame)[!is.element(y, names(data.frame)] Can you solve the problem from here? Best Wishes, Spencer

RE: [R] lm with an arbitrary number of terms

2003-04-02 Thread Vadim Ogranovich
I think you can do it like this lm(y~., data=data.frame) # note the dot to the right of ~ -Original Message- From: Richard Nixon [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 02, 2003 8:50 AM To: [EMAIL PROTECTED] Subject: [R] lm with an arbitrary number of terms Hello