[R] Trend graph
Greg Snow
Greg.Snow at imail.org
Mon Sep 29 18:38:01 CEST 2008
Try this:
pre <- c(1,2,3,4,5)
post <- c(2,5,7,2,3)
plot( 1:2, range(pre,post), type='n', xlab='', ylab='CRP (mg/dl)', xaxt='n')
segments(1,pre,2,post)
axis(1, at=1:2, labels=c('Pre','Post'))
### or one way to label the lines
par(mar=c(5,4,4,4)+0.1)
plot( 1:2, range(pre,post), type='n', xlab='', ylab='CRP (mg/dl)', xaxt='n')
segments(1,pre,2,post)
axis(1, at=1:2, labels=c('Pre','Post'))
tmp.y <- TeachingDemos::spread.labs(post, strheight('1'),
min=min(post), max=max(post))
mtext( 1:5, side=4, at=tmp.y, line=2, las=1 )
hope this helps,
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of C.H.
> Sent: Friday, September 26, 2008 9:54 PM
> To: r-help at r-project.org
> Subject: [R] Trend graph
>
> Dear R Gurus,
>
> I have a problem related to plot.
> For example, I have two variables, pre and post.
>
> pre <- c(1,2,3,4,5)
> post <- c(2,5,7,2,3)
>
> How can I plot a line graph similar to this one?
>
> http://www.pubmedcentral.nih.gov/articlerender.fcgi?artid=1847566&rende
> rtype=figure&id=F1
>
> Would you please provide me a keyword so that I can search. I don't
> know what is the name of this type of graph.
>
> Regards,
> H
>
> --
> CH Chan
> Research Assistant - KWH
> http://www.macgrass.com
>
> ______________________________________________
> R-help at r-project.org 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