[R] R lines type in a glm/predict model

Sarah Goslee sarah.goslee at gmail.com
Mon Sep 14 16:53:37 CEST 2015


It's not clear to me quite what you want, but you might look at the
type="b"
argument to lines, or potentially
?points

Sarah

On Mon, Sep 14, 2015 at 8:11 AM, laurafdez56
<laura.fernandezp at edu.uah.es> wrote:
> Hi everyone!
> I want to change the line type into a square/circle/triangle in a plot, and
> I can not find the way, could someone help me please?? I used the
> glm/predict function to predict the curves.
>
> Here is my code:
>
> glm1<-glm(Supervivencia~Temperatura*Especie,pinos,family=binomial)
>
> range(pinos$Temperatura)
> xv<-5:-30
> sp1<-rep("P.halepensis:-11.6(-10.6,-12)",length(xv))
> sp2<-rep("P.nigra:-23.6(-22.9,-23.9)",length(xv))
> sp3<-rep("P.pinaster:-19.2(-18.7,-19.4)",length(xv))
> sp4<-rep("P.pinea:-12.4(-11.8,-12.7)",length(xv))
> sp5<-rep("P.sylvestris:-21.4(-20.9,-21.6)",length(xv))
> sp6<-rep("P.uncinata:-21.3(-20.7,-21.6)",length(xv))
>
> yv1<-predict(glm1,list(Temperatura=xv,Especie=sp1),type="response")
> yv2<-predict(glm1,list(Temperatura=xv,Especie=sp2),type="response")
> yv3<-predict(glm1,list(Temperatura=xv,Especie=sp3),type="response")
> yv4<-predict(glm1,list(Temperatura=xv,Especie=sp4),type="response")
> yv5<-predict(glm1,list(Temperatura=xv,Especie=sp5),type="response")
> yv6<-predict(glm1,list(Temperatura=xv,Especie=sp6),type="response")
>
>
> plot(Supervivencia~Temperatura,pinos, xlab=(expression(Temperature *
> degree~C)), ylab="Survival",type="n")
> lines(xv,yv1,lwd=2,lty=5, col="black")###halepensis
> lines(xv,yv2,lwd=2,lty=6, col="black")###nigra
> lines(xv,yv3,lwd=2,lty=1, col="black")###pinaster
> lines(xv,yv4,lwd=2,lty=4, col="black")###pinea
> lines(xv,yv5,lwd=2,lty=3, col="black")###sylvestris
> lines(xv,yv6,lwd=2,lty=2, col="black")###uncinta
> abline(0.5,0, col="black", lty=7)
> legend(legend=levels(pinos$Especie),"topleft",bty="n",lty=c(lty=5,lty=6,lty=1,lty=4,lty=3,lty=2))
>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/R-lines-type-in-a-glm-predict-model-tp4712219.html
> Sent from the R help mailing list archive at Nabble.com.
>
-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list