[R] Problem using predict() to draw lines() if predictor variable is logged on the fly

mtb954 at gmail.com mtb954 at gmail.com
Thu Oct 2 18:12:46 CEST 2014


Hello,

I am plotting glms with logged predictors. I would like to define the
logged variables "on the fly" rather than hard coding them into my
dataframe.

This code (with hard-coded logged variables) works just fine:

xx<-seq(-2,.5,by=0.1); lines(xx,predict(power,list(LogArKm00=xx),type=
"response"),col="black",lwd=2,lty=1) #LogArKm00 is a variable in my
dataframe

but my attempt to define them "on the fly" doesn't work (see error below):

plot(log(WbAb,10)~log(ArKm00,10),data=dat) #power model

xx<-seq(-2,.5,by=0.1); lines(xx,predict(power,list(log(ArKm00,10)=xx),type=
"response"),col="black",lwd=2,lty=1) #trying to log the variable "on the
fly"


Error: unexpected '=' in " lines(xx,predict(power,list(log(ArKm00,10)="

I would really appreciate any help sorting this out!

Many thanks

Mark

	[[alternative HTML version deleted]]



More information about the R-help mailing list