[R] Plotting dates

Grum, Mikkel [IPGRI-SSA-Nairobi] m.grum at cgiar.org
Tue Sep 2 16:00:49 CEST 2003


I'm trying to plot observations against observation dates and getting julian
dates along the x-axis:

library(date)
Week<-as.date(c("05/02/03","05/09/03","05/16/03","05/23/03","05/30/03","06/0
7/03","06/14/03"))
Leafminers<-c(0,2,5,10,4,6,5)
Diglyphus<-c(0,0,4,5,7,3,1)
LeafDig<-cbind(Week,Leafminers,Diglyphus)
plot(LeafDig,ylim=c(0,20),main="Leafminers",ylab="Observed
numbers",xlab="",adj=0,bty="l")
points(Diglyphus,pch=2)
lines(Diglyphus,lty=2)
legend(1,18,c("Leafminers","Diglyphus"),lty=c(1,2),pch=c(1,2))

How do I get some more intelligeble dates, like the dates below (but
preferably with 03, ie. 2May03) and spaced with the observations (every
seventh day) rather than the 10 days that seem to be default??

> Week
[1] 2May3  9May3  16May3 23May3 30May3 7Jun3  14Jun3

ALSO, why won't the three last lines of code in the top example show on the
graph?

cheers,
Mikkel



Mikkel Grum
International Plant Genetic Resources Institute (IPGRI)
Sub-Saharan Africa Group
***
PO Box 30677
00100 Nairobi, Kenya
Tel: +254 20 524505(direct)/524500(IPGRI)
Fax: +254 20 524501(IPGRI)/524001(ICRAF)
m.grum at cgiar.org
www.ipgri.org




More information about the R-help mailing list