Error in model.frame.default: variable lengths differ

后端 未结 3 1352
醉梦人生
醉梦人生 2020-12-01 12:11

On running a gam model using the mgcv package, I encountered a strange error message which I am unable to understand:

“Error in model.frame.default(fo

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-01 12:51

    Its simple, just make sure the data type in your columns are the same. For e.g. I faced the same error, that and an another error:

    Error in contrasts<-(*tmp*, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels

    So, I went back to my excel file or csv file, set a filter on the variable throwing me an error and checked if the distinct datatypes are the same. And... Oh! it had numbers and strings, so I converted numbers to string and it worked just fine for me.

提交回复
热议问题