[R] histogramming dates

Michael A. Miller mmiller3 at iupui.edu
Tue May 28 23:57:15 CEST 2002


I'd like to make a plot showing frequency of an event.  The data
is in a data from that includes Year, Month and Day (of month)
fields, so I created a Date with ISOdate(Year, Month, Day,
tz='').  I can plot frequencies for the year 2002 with

  > thisyear <- Date[Year==2002]
  > hist( thisyear, xaxt='n' )
  > axis.POSIXct( 1, at=seq(min(thisyear), max(thisyear), by="month"),
                 format='%b %Y' )

Now I want to specify the histogram breaks so that there is one
bin per month, so I tried this:

  > hist( thisyear,
       breaks=ISOdate( rep(2002,12), seq(12), rep(1,12), tz='' ),
       xaxt='n' )

That resulted in an error message that said:

  Error in Ops.POSIXt(1e-07, mean(h)) : * not defined for POSIXt objects

Can anyone suggest a way to do this?  Or another method for
plotting this sort of month by month frequency plot?  For a
single year I could histogram the month, but I'd like to be able
to span any date range, including multiple years.

Mike

-- 
Michael A. Miller                               mmiller3 at iupui.edu
  Imaging Sciences, Department of Radiology, IU School of Medicine
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list