Generalized additive model data.frame.default error: attempting to apply nonfunction

前端 未结 1 1731
遇见更好的自我
遇见更好的自我 2021-01-23 05:43

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         


        
相关标签:
1条回答
  • 2021-01-23 06:33

    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 contain NAs. The default is set by the na.action setting of options, and is na.fail if that is unset. The factory-fresh default is na.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
    
    0 讨论(0)
提交回复
热议问题