Re: [R] different points and lines on the same plot

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Sun 07 Jan 2007 - 14:32:54 GMT

Try this:

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

On 1/7/07, antoniababe@yahoo.se <antoniababe@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@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.
>



R-help@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. Received on Mon Jan 08 01:37:18 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 08 Jan 2007 - 23:30:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.