[R] different points and lines on the same plot

Gabor Grothendieck ggrothendieck at gmail.com
Sun Jan 7 15:32:54 CET 2007


Try this:

matplot(patient[,1], patient[,-1], type = "o")


On 1/7/07, antoniababe at yahoo.se <antoniababe at yahoo.se> wrote:
> Dear all,
>
> I have following data called "paitent"
>
> day    patient1    patient4    patient5    patient6
> 0   -0.27842688 -0.04080808 -0.41948398 -0.04508318
> 56  -0.22275425 -0.01767067 -0.30977249 -0.03168185
> 112 -0.08217659 -0.26209243 -0.29141451 -0.09876170
> 252  0.08044537 -0.26701769  0.05727087 -0.09663701
>
> where each patient have response values at four time
> points. I want to plot each patient's values over time
> on the same plot where the value points are connected
> by line. That is, the graph will have four lines for
> the four patients. I tried the program below but
> couldn't make it work correctly. I'm new beginner and
> haven't yet learned how functions line and points work
> together. Hope you can help me out.
>
> Thanks for your help,
>
> Antonia
>
> par(mfrow=c(1,1))
>        plot(patient[,1],patient[,2], pch=1,
> type="l",col=1,cex=1,lwd=2,
>             xlab="Days", ylab="Patient
> response",cex.main =1,font.main= 1,
>             main=NULL)
>
>
> points(patient[,1],patient[,3],col=2,pch=1,cex=1)
> lines(patient[,1],patient[,3],col=2,lty=1,cex=1)
>
> points(patient[,1],patient[,4],col=3,pch=1,cex=1)
> lines(patient[,1],patient[,4],col=2,lty=2,cex=1)
>
> points(patient[,1],patient[,5],col=4,pch=1,cex=1)
> lines(patient[,1],patient[,5],col=2,lty=1,cex=1)
>  points(patient[,1],patient[,6],col=5,pch=1,cex=1)
>  lines(patient[,1],patient[,6],col=2,lty=1,cex=1)
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> 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.
>



More information about the R-help mailing list