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

From: Ola Caster <ola.caster_at_gmail.com>
Date: Fri, 09 May 2008 11:19:26 +0200

Sorry for spamming the list...

I noticed that if you first produce a date histogram with the hist() function, like this:

basic.histogram <- hist(my.data$date, breaks = "months", plot = FALSE)

and then try to transfer the breaks from that histogram to a lattice equivalent, like this:

histogram(~date, data=my.data, breaks=basic.histogram$breaks)

then I get a histogram that looks exactly like the original one, except the bins are not placed correctly on the x-axis. In my case they were all shifted almost a year to the right. Does anyone know why this happened and if there is a way to deal with it?

Many thanks
Ola

2008/5/9 Ola Caster <ola.caster_at_gmail.com>:

>
>
> Thanks a lot Deepayan. Could you please inform me what update are you
> referring to, and give me some very vague sense when it might happen (within
> weeks, months, or years)?
>
> Many thanks
> Ola
>
> 2008/5/8 Deepayan Sarkar <deepayan.sarkar_at_gmail.com>:
>
> 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
>>
>
>

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 09 May 2008 - 09:23:17 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 09 May 2008 - 20:32:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive