how to solve predict.lm() error: variable 'affinity' was fitted with type “nmatrix.1” but type “numeric” was supplied
问题 I have a simple linear model: mylm = lm(formula = prodRate~affinity, mydf) where mydf is a dataframe which looks like: prodRate affinity 1 2643.5744 0.005164040 2 2347.6923 0.004439970 3 1783.6819 0.003322830 when I use predict.lm() an error came up: my_pred= predict(mylm,newdata=data.frame(affinity=seq(0,1,0.1)) ) Error: variable 'affinity' was fitted with type "nmatrix.1" but type "numeric" was supplied. Why is that? how to fix it? Thanks! 回答1: Thanks to the discussion with user20650 (see