tally events {epicalc}R Documentation

Tally a date variable by larger time unit

Description

Tabulate dates breakdown by week, month or year and plot the results

Usage

## S3 method for class 'events'
tally(x, by=NULL, breaks=c("day","week","month","year"), 
       graph=TRUE, type="l", line.col="auto", legend = TRUE, legend.site="topright", 
       legend.bg = "white", ylim="auto", cex=1, addmargins=TRUE, ...) 

Arguments

x

a date variable

by

a grouping elements

breaks

time unit for aggregation of the events

graph

whether the table be plotted

type

graph type

line.col

line colour

legend

wheter the legend will be produced if there are more than one groups

legend.site

a single character string indicating location of the legend. See details of ?legend

legend.bg

background colour of the legend

ylim

Y axis limits

cex

character expanding factor for the legend

addmargins

whether the margin values of the cross-table will be computed

...

additional graphic parameters passed on to other methods

Details

This function produces table of events by day, month or year with zero cells included. It also plots the table.

'by' is a grouping variable, usually a factor.

'breaks' can be "day", "week", "month" and "year".

'type' can be "l", "p", "b", "c", "o", "h", "s" and "S" only when there is only group (by=NULL). Otherwise, graph type will be 'l'.

'line.col' control line colours in the graph and the legend

If 'legend = TRUE" (by default), a legend box is automatically drawn on the "topright" corner of the graph. This character string can be changed to others such as, "topleft", "center", etc (see examples).

Author(s)

Virasakdi Chongsuvivatwong <cvirasak@medicine.psu.ac.th>

See Also

'dotplot'

Examples

random.dates <- as.Date("2001/1/1") + round(20*stats::runif(100))
tally.events(random.dates)
tally.events(random.dates, las=2)
tally.events(random.dates, las=2, type = "h", lwd =2, ylim = c(0,20))
random.dates2 <- as.Date("2001/1/1") + round(500*stats::runif(100))
gender100 <- c(rep("F", 50),rep("M", 50))
tally.events(random.dates2, las=2, breaks="week")
tally.events(random.dates2, las=2, breaks="month", type="h")
tally.events(random.dates2, breaks="week", by=gender100)
tally.events(random.dates2, breaks="month", by=gender100, cex=2, line.col=c("blue","brown"), lwd=2)

[Package epicalc version 3.5.1.8 Index]