[R] histogramming dates

Don MacQueen macq at llnl.gov
Wed May 29 03:37:36 CEST 2002

One way would be to convert to POSIXlt and extract the month element. 
Then you should be able to tabulate the number of events in each 
month, and make a barplot of those.

At 4:57 PM -0500 5/28/02, Michael A. Miller wrote:
>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.
>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

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