[R] histogram() with "Date" class?

Deepayan Sarkar
2008-05-08T20:09:23Z

On 5/8/08, Ola Caster <ola.caster at gmail.com>
wrote:
> Dear help list,
>
>  Is it possible to draw lattice histograms (i.e. use the histogram()
function
>  and not the hist() function) with objects of class "Date"?

Sort of. The default calculation of 'breaks' doesn't work, so

histogram(~date, data=my.data)

will currently fail (I will fix this in the next update). However,

histogram(~date, data=my.data, breaks = 10)
histogram(~date, data=my.data, breaks = "fd")

etc., should work. The help page for histogram is somewhat ambiguous; it says:

  breaks:

          [...]

          Other valid values
          of 'breaks' are those of the 'breaks' argument in
'hist'.
          This allows specification of 'breaks' as an integer giving
          the number of bins (similar to 'nint'), as a character string
          denoting a method, and as a function.

What is meant here is that valid values of breaks in 'hist.default'
will work, not those for any other methods. In particular, breaks
"months" will not work.

-Deepayan

>  I've tried solutions like
>
>  histogram(~date, data=my.data, breaks="months")
>
>  but it doesn't seem to work.
>
>  Any suggestions are welcome.
>
>  Many thanks
>  Ola Caster