impute_date: Impute a vector of dates

Description Usage Arguments Details Value See Also Examples

View source: R/impute.R

Description

Given years, and possibly months and days, randomly generate a dates. The dates are generated from a uniform distribution: all dates that fall within the range implied by the year, month, and day arguments have the same chance of being selected. For instance, if year is 2000, month is "March", and no value is supplied for date, then every date from "2000-03-01" to "2000-03-31" has the same 1/31 chance of being selected.

Usage

1
impute_date(year, month = NULL, day = NULL)

Arguments

year

A numeric vector specifying years. Required.

month

A numeric or character vector specifying months. Optional.

day

A numeric vector specifying days. Optional

Details

Months can be specified in one of four ways:

  1. Numbers 1, 2, ..., 12

  2. Codes "01", "02", ..., "12"

  3. English full names: "January", "February", ..., "December"

  4. English abbreviations: "Jan", "Feb", ..., "Dec"

month and day, if supplied, must have the same length as year.

Value

A vector of class Date.

See Also

impute_dob

Examples

1
2
3
4
5
impute_date(year = 2000:2004)
impute_date(year = 2000:2004,
            month = c("Feb", "Jun", "May", "Apr", "Feb"))
impute_date(year = 2000:2004,
            day = c(3, 31, 11, 2, NA))

johnrbryant/demprep documentation built on Dec. 31, 2021, 11:58 a.m.