Eric Fail wrote:
Hi Ruser
As so usual I'm trying to replicate some SAS code. I wold like to know
if there is a wildcard operators, as " : " in SAS, in R?
When running:
lm(y ~ x1 + x2 + x3 + x4 + x5 + x6 .... x9860, data=mydata)
I would like to be able to get around it by just writing something like
this:
lm(y ~ x1:x9860, data=mydata)
See ?formula, specifically:
There are two special interpretations of ‘.’ in a formula. The
usual one is in the context of a ‘data’ argument of model fitting
functions and means ‘all columns not otherwise in the formula’:
see ‘terms.formula’. In the context of ‘update.formula’, *only*,
it means ‘what was previously in this part of the formula’.
So assuming all those RHS variables + y make up your data.frame
lm(y ~ ., data = mydata) would be fine. You can easily create such a data.frame
if you don't already have it using regexs.
--Erik
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.