I have question regarding the lm()
function in R.
I understand that lm()
is used for regression modeling and I know that one can do this:
lm(response ~ explanatory1 + explanatory2 + ... + explanatoryN, data = dataset)
Now my question is: "Suppose that N
is large, is there a short cut that I can use that doesn't involve me having to write all N
variable names?"
Thanks in advance!
Edit: I left out a big part of the question that I really needed an answer to. Suppose that I wanted to remove 1
to k
explanatory variables and only include n-k
of those variables.
lm(reformulate(paste0("explanatory", 1:5), "response"), data=dataset)
. – Twosided