The special name . may be used on the right side of the ~ operator,
to stand for all the variables in a data.frame other than the response.
--John Chambers, Statistical Models in S, p. 101
So, if the y and Xi (in your case) were the only variables in mydata, then
lm(y ~ . , data = mydata)
Two possible ways around this are
1. If the x's are *all* the other variables in your data frame you can use a
dot:
fm - lm(y ~ ., data = myData)
2. Here is another idea
as.formula(paste(y~, paste(x,1:10, sep=, collapse=+)))
y ~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10
(You bore
You can construct the formula on the fly. Say you have a data frame with
columns: y, x1,...x10:
dat - data.frame(matrix(rnorm(1100), ncol=11, dimnames=list(NULL,c(y,
paste(x, 1:10, sep=)
Then you could construct the formula using:
form - formula(paste(y ~ , paste(names(dat)[which(names(dat)
Yet again my baroque programming style shows itself. The . notation is
great, although solution 2. is perhaps more versatile, allowing you to
pick and choose your predictors more easily.
On Thu, 2008-11-13 at 11:56 +1100, [EMAIL PROTECTED] wrote:
Two possible ways around this are
1. If the
4 matches
Mail list logo