Convert a Date Character Vector into a Date ObjectSource:
Convert a date character vector (usually '--DTC') into a Date vector (usually '--DT').
convert_dtc_to_dt( dtc, highest_imputation = "n", date_imputation = "first", min_dates = NULL, max_dates = NULL, preserve = FALSE )
The --DTC date to convert.
Highest imputation level
highest_imputationargument controls which components of the DTC value are imputed if they are missing. All components up to the specified level are imputed.
If a component at a higher level than the highest imputation level is missing,
NA_character_is returned. For example, for
highest_imputation = "D"
NA_character_because the month is missing.
"n"is specified no imputation is performed, i.e., if any component is missing,
max_datesshould be specified respectively. Otherwise,
NA_character_is returned if the year component is missing.
"Y"(year, highest level),
"n"(none, lowest level)
The value to impute the day/month when a datepart is missing.
A character value is expected, either as a
format with month and day specified as
"06-15"for the 15th of June (The year can not be specified; for imputing the year
max_datesargument can be used (see examples).),
or as a keyword:
"last"to impute to the first/mid/last day/month.
The argument is ignored if
highest_imputationis less then
A list of dates is expected. It is ensured that the imputed date is not before any of the specified dates, e.g., that the imputed adverse event start date is not before the first treatment date. Only dates which are in the range of possible dates of the
dtcvalue are considered. The possible dates are defined by the missing parts of the
dtcdate (see example below). This ensures that the non-missing parts of the
dtcdate are not changed. A date or date-time object is expected. For example
impute_dtc_dtm( "2020-11", min_dates = list( ymd_hms("2020-12-06T12:12:12"), ymd_hms("2020-11-11T11:11:11") ), highest_imputation = "M" )
"2020-11-11T11:11:11"because the possible dates for
"2020-12-06T12:12:12"is ignored. Returning
"2020-12-06T12:12:12"would have changed the month although it is not missing (in the
A list of dates is expected. It is ensured that the imputed date is not after any of the specified dates, e.g., that the imputed date is not after the data cut off date. Only dates which are in the range of possible dates are considered. A date or date-time object is expected.
Preserve day if month is missing and day is present
preserve = TRUE(and
date_imputation = "MID").
Date/Time Computation Functions that returns a vector: