[R] question on plot dates

Prof Brian Ripley ripley at stats.ox.ac.uk
Sun Apr 11 22:32:59 CEST 2004


On Sun, 11 Apr 2004, Linda portman wrote:

> I am trying to plot "time" variable (the time is recoded for three days at 5 minutes interval in the format of 2001-05-14 13:45:00)  VS. blood pressure. My code is the following: 
>  
>  
> plot(time, bloodpressure,xlab="Time",ylab="bPress",main="Time VS Blood Pressure", type="l", xaxt="n")
>  r <- as.POSIXct(round(range(Time), "days"))
>  axis.POSIXct(1, at=seq(r[1], r[2], by="day"), format="%d-%b")

>  However the plot only shows three values 14-Apr, 15-Apr and 16 Apr, I
> would like to have 24 hours marked on the x axis for each day. How can I
> do it?  Thanks a lot!

You asked for exactly values by day, so is it so surprising that you got 
what you asked for?  (That's the point of at vs x.)  Try by="hour" with a 
suitable format.

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