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

Michael Dewey lists at dewey.myzen.co.uk
Mon Sep 14 17:34:57 CEST 2015


Dear Laura

The line type is usually something like: solid, dotted, dashed, ...
The shapes you suggest are usually point symbols.

When you repost perhaps it would be a good idea to
1 - give us a small dataset
2 - just supply code for two species
3 - tell us what you see, and what you really wanted to see

On 14/09/2015 13:11, laurafdez56 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.
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Michael
http://www.dewey.myzen.co.uk/home.html



More information about the R-help mailing list