cum_dates: The total number of events through time (in days)

View source: R/cum_dates.R

cum_datesR Documentation

The total number of events through time (in days)

Description

Calculate the total number of events by each date in a series of dates (i.e., a cumulative frequency distribution).

Usage

cum_dates(data, ...)

Arguments

data

A vector of dates.

...

Other arguments passed to as.Date.

Value

The function returns a dataframe with three columns: (1) 'date', the date; (2) 'freq', the number of observations on each unique date; and (3) 'cumul', the total number of events by each date (i.e. the cumulative frequency).

Author(s)

Edward Lavender

Examples


#### Example (1): A simple sequence of dates
cum_dates(seq.Date(as.Date("2016-01-01"), as.Date("2016-01-10"), 1))

#### Example (2): Multiple records of each date
set.seed(1)
dates <- seq.Date(as.Date("2016-01-01"), as.Date("2016-01-10"), 1)
dates <- sort(sample(dates, size = 1000, replace = TRUE))
cum_dates(dates)


edwardlavender/Tools4ETS documentation built on Nov. 29, 2022, 7:41 a.m.