[R] Time series graphs

Scionforbai scionforbai at gmail.com
Thu Sep 20 21:19:05 CEST 2007


In pure R (without other packages) is IMHO simpler to understand (at
least if data are so simple: months 1 till 9 with no missing
values...). All you need is:

dummybob <- ' month A B
 Jan   8 4
 Feb   7 5
 Mar   6 8
 Apr   3 7
 May   5 1
 Jun   6 4
 Jul   2 8
 Aug   1 2
 Sep   4 3
'

bob <- read.table(textConnection(dummybob), head=TRUE,
stringsAsFactors = FALSE)

plot(0,0,"n",xlim=c(1,9),ylim=c(0,9),xlab="Month",ylab="Value",axes=FALSE)
title(main="Bob")
lines(1:9,bob$A,lty="solid",col="black")
lines(1:9,bob$B,lty="dotted",col="green")
axis(1,1:9,bob$month)
axis(2)

text(1:9,bob$A,"A",pos=3)
text(1:9,bob$B,"B",pos=3)
box()

And then repeat with the other dataset.



More information about the R-help mailing list