resolve | R Documentation |

This collection of S3 methods 'resolve' messy dates into a single date according to some explicit bias, such as returning the minimum or maximum date, the mean, median, or modal date, or a random date from among the possible resolutions for each messy date. If the date is not 'messy' (i.e. has no annotations) then just that precise date is returned. This can be useful for various descriptive or inferential projects.

## S3 method for class 'mdate' min(..., na.rm = TRUE) ## S3 method for class 'mdate' max(..., na.rm = TRUE) ## S3 method for class 'mdate' median(..., na.rm = TRUE) ## S3 method for class 'mdate' mean(..., trim = 0, na.rm = TRUE) modal(..., na.rm = FALSE) ## S3 method for class 'mdate' modal(..., na.rm = TRUE) random(..., size, replace = FALSE, prob = NULL) ## S3 method for class 'mdate' random(..., size, replace = FALSE, prob = NULL)

`...` |
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. |

`size` |
a non-negative integer giving the number of items to choose. |

`replace` |
should sampling be with replacement? |

`prob` |
a vector of probability weights for obtaining the elements of the vector being sampled. |

A single scalar or vector of dates

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")) d min(d) max(d) mean(d) median(d) modal(d) random(d)

messydates documentation built on Jan. 22, 2023, 1:36 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.