[R] datetime data and plotting

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Oct 17 18:05:33 CEST 2003


I am not seeing this on Linux.  The x axis marks are at midnight GMT, 
hence 1am BST on my system.

On Fri, 17 Oct 2003, Jacob Etches wrote:

> If I take the following simple data:
> 
> YEAR MONTH DAY WEIGHT.KG
> 2003 10 6 1.2
> 2003 10 12 1.2
> 2003 10 16 1.3
> 
> and format the date data and plot it:
> 
> dates <- strptime(paste(DAY,MONTH,YEAR),"%d%m%Y")
> plot(c(min(dates),max(dates)),c(0,max(WEIGHT.KG)),
>  xlab="Date",ylab="Weight (kg)",type="n")
>  lines(dates,WEIGHT.KG)
>  points(dates,WEIGHT.KG)
> 
> I find that the data points are all plotted at (x-1,y),
> where x is in days.  Have I requested this behaviour 
> accidentally?  I'm using R-1.8 on OS X.
> 
> Printing the dates object looks correct, and simple 
> manipulations such as max(dates)-min(dates) behave 
> normally.
> 
> Jacob Etches
> 
> Doctoral candidate
> Dept of Public Health Sciences
> University of Toronto
> 
> 

-- 
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