Description Usage Arguments Value Author(s) Examples
View source: R/derive_date_vars.R
Imputation partial date/time portion of a '--DTC'
variable. based on user
input.
1 2 3 4 5 6 7 8 | impute_dtc(
dtc,
date_imputation = NULL,
time_imputation = "00:00:00",
min_dates = NULL,
max_dates = NULL,
preserve = FALSE
)
|
dtc |
The A character date is expected in a format like |
date_imputation |
The value to impute the day/month when a datepart is missing. If Otherwise, a character value is expected, either as a
Default is |
time_imputation |
The value to impute the time when a timepart is missing. A character value is expected, either as a
Default is |
min_dates |
Minimum dates 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 impute_dtc( "2020-11", min_dates = list( ymd_hms("2020-12-06T12:12:12"), ymd_hms("2020-11-11T11:11:11") ), date_imputation = "first" ) returns |
max_dates |
Maximum dates 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. |
preserve |
Preserve day if month is missing and day is present For example Permitted Values: Default: |
A character vector
Samia Kabi
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | library(lubridate)
dates <- c(
"2019-07-18T15:25:40",
"2019-07-18T15:25",
"2019-07-18T15",
"2019-07-18",
"2019-02",
"2019",
"2019",
"2019---07",
""
)
# No date imputation (date_imputation defaulted to NULL)
# Missing time part imputed with 00:00:00 portion by default
impute_dtc(dtc = dates)
# No date imputation (date_imputation defaulted to NULL)
# Missing time part imputed with 23:59:59 portion
impute_dtc(
dtc = dates,
time_imputation = "23:59:59"
)
# Same as above
impute_dtc(
dtc = dates,
time_imputation = "LAST"
)
# Impute to first day/month if date is partial
# Missing time part imputed with 00:00:00 portion by default
impute_dtc(
dtc = dates,
date_imputation = "01-01"
)
# same as above
impute_dtc(
dtc = dates,
date_imputation = "FIRST"
)
# Impute to last day/month if date is partial
# Missing time part imputed with 23:59:59 portion
impute_dtc(
dtc = dates,
date_imputation = "LAST",
time_imputation = "LAST"
)
# Impute to mid day/month if date is partial
# Missing time part imputed with 00:00:00 portion by default
impute_dtc(
dtc = dates,
date_imputation = "MID"
)
# Impute a date and ensure that the imputed date is not before a list of
# minimum dates
impute_dtc(
"2020-12",
min_dates = list(
ymd_hms("2020-12-06T12:12:12"),
ymd_hms("2020-11-11T11:11:11")
),
date_imputation = "first"
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.