[R] Changing X axis of ggplot

Aren Cambre aren at arencambre.com
Tue Jan 3 22:25:43 CET 2012


I'm not sure I know yet what I'm looking for. :-)

I have a list of all traffic tickets written in Dallas, TX over a few
years. One of the first things I am doing is reviewing the data to
make sure the quality is good; I'm trying to see whether it just looks
right.

One measure is whether the volume of tickets written each hour of the
day make sense.

I've converted each ticket's time into a times class (from the chron
package). The problem is that this is expressed as a decimal value
between 0 and 1. For example, take 0.538194444444444. That is the
underlying value behind a times object.

0.538194444444444 * 24 = 12.916666666666656. OK, so this is 12 noon
and some minutes.

0.916666666666656 * 60 = 55. OK, it's 12:55 PM.

Now if I put these times in a barplot, I'd like to group by each hour,
which would be increments of 1/24 = 0.041667. And I'd like the labels
on the X axis to be like 1 AM, 2 AM, 3 AM instead of 0.041667,
0.08333, and 0.125.

I'm not clear how to do this with ggplot.

Aren

On Tue, Jan 3, 2012 at 8:40 AM, Hasan Diwan <hasan.diwan at gmail.com> wrote:
> Aren,
> Perhaps putting the sort of visualisation you'd like in a
> web-accessible location would be helpful?
>
> --
> Sent from my mobile device
> Envoyait de mon portable



More information about the R-help mailing list