from_messydate: Coercion from messy dates

Description Usage Arguments Value Examples

Description

These functions coerce objects of messydt class to common date classes such as Date, POSIXct, and POSIXlt. Since messydt objects can hold multiple individual dates, however, an additional function must be passed as an argument so that these functions know how to coerce resolve multiple dates into a single date.

For example, one might wish to use the earliest possible date in any ranges of dates (min), the latest possible date (max), some notion of a central tendency (mean, median, or modal), or even a random selection from amongst the candidate dates.

These functions then, building on expand() and the resolve functions, are particularly useful in converting back out of the messydt class for use with existing methods and models, especially for checking the robustness of results.

Usage

1
2
3
4
5
6
7
8
## S3 method for class 'messydt'
as.Date(x, ..., FUN)

## S3 method for class 'messydt'
as.POSIXct(x, ..., FUN)

## S3 method for class 'messydt'
as.POSIXlt(x, ..., FUN)

Arguments

x

A messydt object

...

Arguments passed on to the S3 generics.

FUN

A function that can be used to resolve expanded messy dates into a single date. For example, min(), max(), mean(), median(), modal(), and random().

Value

A date object of Date, POSIXct, or POSIXlt class

Examples

1
2
3
4
5
6
as.Date(as_messydate("2012-01"), min)
as.Date(as_messydate("2012-01"), mean)
as.Date(as_messydate("2012-01"), max)
as.Date(as_messydate("2012-01"), median)
as.Date(as_messydate("2012-01"), modal)
as.Date(as_messydate("2012-01"), random)

messydates documentation built on Nov. 12, 2021, 5:06 p.m.