I'm using model.frame()
in R (to use within a function) but I can't manage to exclude some of the variables with the formula by using -
.
For example, in a data frame (data) with variables "y", "x1", "x2" and "x3", by using:
model.frame(y ~ . - x3, data)
I would get a data frame including all "y", "x1", "x2" and "x3".
Is there a way to exclude "x3" using a formula and not removing the variable directly as in:data[,-4]
?