eventCounts {gamclass} | R Documentation |
Tabulate vector of dates by specified time event
Description
For example, dates may be dates of plane crashes. For purposes of analysis, this function tabulates number of crash events per event of time, for each successive specified event.
Usage
eventCounts(data, dateCol="Date", from = NULL, to = NULL,
by = "1 month", categoryCol=NULL, takeOnly=NULL, prefix="n_")
Arguments
data |
Data frame that should include any columns whose names appear in other function arguments. |
dateCol |
Name of column that holds vector of dates |
from |
Starting date. If |
to |
Final date, for which numbers of events are to be tallied. If
|
by |
Time event to be used; e.g. "1 day", or "1 week", or "4 weeks", or "1 month", or "1 quarter", or "1 year", or "10 years". |
categoryCol |
If not |
takeOnly |
If not |
prefix |
If |
Value
A data frame, with columns Date
(the first day of the
event for which events are given), and other column(s) that
hols counts of events.
Author(s)
John Maindonald
See Also
Examples
crashDate <- as.Date(c("1908-09-17","1912-07-12","1913-08-06",
"1913-09-09","1913-10-17"))
df <- data.frame(date=crashDate)
byYears <- eventCounts(data=df, dateCol="date",
from=as.Date("1908-01-01"),
by="1 year")