eventCounts | R Documentation |
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.
eventCounts(data, dateCol="Date", from = NULL, to = NULL,
by = "1 month", categoryCol=NULL, takeOnly=NULL, prefix="n_")
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 |
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.
John Maindonald
cut
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.