impute_pdates {sdtmval} | R Documentation |
Impute start or end dates
Description
Imputes missing date elements for start or end dates. Partial dates should be
in the format "UNKN-UN-UN"
or some combination of those characters and
numbers (ie "2017-UN-UN"
). Dates with no information or dates with a
missing year will be converted to NA
. For start dates, missing days are
assumed to be the first of the month while missing months are assumed to be
January. For end dates, missing days are assumed to be the last day of the
month and missing months are assumed to be December.
Usage
impute_pdates(dates, ptype, input_sep = "-")
Arguments
dates |
a character vector of partial dates (which could also contain full dates) in the format YYYY-MM-DD |
ptype |
a string of either |
input_sep |
the character that separates date components in |
Value
a date vector of imputed dates in the format YYYY-MM-DD
See Also
reshape_adates()
, reshape_pdates()
, trim_dates()
,
vignette("Dates")
Examples
dates <- c(
"UNKN-UN-UN",
"2017-UN-UN",
"2017-02-UN",
"2017-UN-05",
"2017-09-03",
"UNKN-07-14",
NA
)
impute_pdates(dates, ptype = "start")
impute_pdates(dates, ptype = "end")