[R] Strange labels on plot with dates

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Apr 3 16:04:48 CEST 2007


PLEASE do read the posting guide and give us the ouput it asks for.
Current R (2.5.0 alpha) does give 2001, 2002, ..., so you did not follow 
the request to update your R, I suspect.

On Tue, 3 Apr 2007, Henrik Andersson wrote:

> Hello fellow R people,
>
> I don't understand the default behavior of the axis labeling when
> plotting dates.
>
> I would expect something like 2001, 2002 or possibly Jan 01, Jan
> 02...Jan 06, but instead I only see Jan 01, Jan 01, Jan 01....
>
>
> See the following example
>
> startdate <- strptime("2001-01-01",format="%Y-%m-%d")
> enddate <- strptime("2006-12-31",format="%Y-%m-%d")
> dates <- seq(startdate,enddate,by="month")
>
> daynr <- as.numeric(julian(dates,origin=dates[1]))
>
> yvar <- sin(daynr*2*pi/365)
>
> plot(yvar~dates,type='l')
>
> Cheers, Henrik
>
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list