[R] Plotting dates

Heywood, Giles Giles.Heywood at CommerzbankIB.com
Tue Sep 2 16:58:42 CEST 2003


One solution is to use the Irregular Time-Series (its) package
on CRAN.

LeafDig <- cbind(Leafminers,Diglyphus)
dimnames(LeafDig)[[1]] <-
c("05/02/03","05/09/03","05/16/03","05/23/03","05/30/03","06/07/03","06/14/0
3")
require("its")
its.format("%m/%d/%y")
plot(its(LeafDig),format="%d %b %y")

You can select date format you require via the format parameter.

Giles

> -----Original Message-----
> From: Grum, Mikkel [IPGRI-SSA-Nairobi] [mailto:m.grum at cgiar.org]
> Sent: 02 September 2003 15:01
> To: r-help at stat.math.ethz.ch
> Subject: [R] Plotting dates
> 
> 
> 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","0
> 5/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
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 


********************************************************************** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}




More information about the R-help mailing list