[R] Trend graph

Jim Lemon jim at bitwrit.com.au
Sat Sep 27 14:03:27 CEST 2008


C.H. wrote:
> 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&rendertype=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.
>
>   
Hi Chainsaw (both my wife and I like chainsaws),

I would use lines - I don't know of any specific function that will do this.

pp.mat<-cbind(pre,post)
plot(1:2,c(1,7),type="n",xaxt="n")
axis(1,at=1:2)
apply(pp.mat,1,lines)

Jim



More information about the R-help mailing list