[R] predict(lm(etc.), some_data) -> "numeric envir arg not of length one " ???

Bruce LaZerte mail at fwr.on.ca
Thu Aug 7 16:35:39 CEST 2003


I've got a data frame with two numeric variables, df$flow and df$flow1.

> tl <- lm(flow~flow1,df,na.action=na.exclude)
> tlo <- loess(flow~flow1,df,na.action=na.exclude)

Both loess and a simple linear model fit the data well. 
summary(tl) and summary(tlo) seem reasonable. As do plots such as: 
plot(predict(tl),df$flow)
plot(predict(tlo),df$flow)

I want to replace missing values of  df$flow from df$flow1:

> p <- is.na(df$flow) 
> df$flow[p] <- predict(tl,df$flow1[p])
Error in eval(expr, envir, enclos) : numeric envir arg not of length one
???

> df$flow[p]<- predict(tlo,df$flow1[p])
This loess prediction works however.

Could someone explain the linear model's "numeric envir arg not of length one" error for me?

Thanks in advance ...
Bruce L.
__________________________________________
Bruce LaZerte 
Grandview Lake in Muskoka
Baysville, Ontario, Canada




More information about the R-help mailing list