Learn R Programming

messydates (version 0.5.4)

coerce_tendency: Resolves messy dates into a central tendency

Description

These functions resolve messydates by their central tendency. While the functions mean(), median(), and modal() summarise the vector to a single value, v*() versions return a vector of the same length.

Usage

# S3 method for mdate
median(..., na.rm = TRUE)

vmedian(..., na.rm = TRUE)

# S3 method for mdate vmedian(..., na.rm = TRUE)

# S3 method for mdate mean(..., trim = 0, na.rm = TRUE)

vmean(..., na.rm = TRUE)

# S3 method for mdate vmean(..., trim = 0, na.rm = TRUE)

modal(..., na.rm = TRUE)

# S3 method for mdate modal(..., na.rm = TRUE)

vmodal(..., na.rm = TRUE)

# S3 method for mdate vmodal(..., na.rm = TRUE)

random(..., na.rm = TRUE)

# S3 method for mdate random(..., na.rm = TRUE)

vrandom(..., na.rm = TRUE)

# S3 method for mdate vrandom(..., na.rm = TRUE)

Arguments

...

a mdate object

na.rm

Should NAs be removed? True by default.

trim

the fraction (0 to 0.5) of observations to be trimmed from each end of x before the mean is computed. Values of trim outside that range are taken as the nearest endpoint.

Examples

Run this code
d <- as_messydate(c("2008-03-25", "?2012-02-27", "2001-01?", "2001~",
  "2001-01-01..2001-02-02", "{2001-01-01,2001-02-02}",
  "{2001-01,2001-02-02}", "2008-XX-31", "-0050-01-01"))
d
median(d)
vmedian(d)
mean(d)
vmean(d)
modal(d)
vmodal(d)
random(d)
vrandom(d)

Run the code above in your browser using DataLab