I am trying to run a general additive model using the mgcv package, but I keep getting a model.frame.default error:
Error in model.frame.default(formula = Prese
The problem is this
na.action = TRUE
na.action
requires a function and you passed it a logical, (from ?bam
)
na.action
: a function which indicates what should happen when the data containNA
s. The default is set by thena.action
setting ofoptions
, and isna.fail
if that is unset. The factory-fresh default isna.omit
.
Essentially, within model.frame()
you were basically asking R to evaluate
TRUE(df)
which rightly throws an error as TRUE
isn't a function yet was being called as one.
If you want to omit rows with NA
s rather than fail if they occur, use
na.action = na.omit