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 containNAs. The default is set by thena.actionsetting ofoptions, and isna.failif 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 NAs rather than fail if they occur, use
na.action = na.omit