[R] How to plot a histogram of weekday frequencies in a list of dates?

David Stark davidestark at gmail.com
Thu Jul 15 18:24:08 CEST 2010


Question from an [R] novice...
Hi,
I have a vector of date/times like the one shown below (a truncated
sample of a much longer list...)

> dates[1:4]
[1] "2006-03-16 08:41:00" "2006-03-16 10:28:00" "2006-03-16 11:03:00"
[4] "2006-03-16 11:04:00"

I would like to generate a weekday histogram showing the frequency of
dates falling on each weekday. I know that the function weekdays()
gives me the weekday for each date in my vector, but the hist()
function can't plot non-numeric values. There should be a function to
allow me to do this simply. Any thoughts?

After having done this, I would also like to bin my histogram in 12 hr
periods (Mon 7am - 7pm; Mon 7pm - Tues 7am; Tues 7am - 7pm; Tues
7pm-Wed 7am... etc) so that I can plot the frequency of event
occurrences within each 12 hour period over the course of a week. Any
help would be greatly appreciated. Thanks

David



More information about the R-help mailing list