I have to add approximately 30 dummy variables to a regression.
If my variables would be named dummy1
- dummy30
, I would denote this with an asterisk wildcard in STATA
. It would be simply regress y dummy*
and STATA
would add all variables starting with 'dummy'.
Can anyone hint me to a similar convenient procedure in [R]
which prevents me from writing out 30 variable names?
y ~ ., data = <a data.frame with only the columns you want to include in your regression, where you can use a regular expression for subsetting>
y ~ .
formula).as.factor()
.