This question already has an answer here:
- short formula call for many variables when building a model [duplicate] 2 answers
It appears simple, but I don't know how to code it in R. I have a dataframe (df) with ~100 variables, and I would like to do a multiple regression between the response which is my First variable (Y) and the variables 25 to 60 as regressors. The problem is that I don't want to write each variable name like:
lm(Y~var25+var26+.......var60, data=df)
I would like to use something like [, 25:60] to select a complete range. I have tried it but doesn't works:
test <- lm(Y~df[, 25:60], data=df)
summary(test)
some idea?