I have a dataframe with let\'s say N+2 columns. The first is just dates (mainly used for plotting later on), the second is a variable whose response to the remaining N colu
Using the formula notation y ~ . specifies that you want to regress y on all of the other variables in the dataset.
df = data.frame(y = 1:10, x1 = runif(10), x2 = rnorm(10))
# fits a model using x1 and x2
fit <- lm(y ~ ., data = df)
# Removes the column containing x1 so regression on x2 only
fit <- lm(y ~ ., data = df[, -2])