Compute the number of days till the end of the observation period at a certain date
Source:R/addDemographics.R
addFutureObservation.Rd
Compute the number of days till the end of the observation period at a certain date
Usage
addFutureObservation(
x,
indexDate = "cohort_start_date",
futureObservationName = "future_observation",
futureObservationType = "days"
)
Arguments
- x
Table with individuals in the cdm.
- indexDate
Variable in x that contains the date to compute the future observation.
- futureObservationName
name of the new column to be added.
- futureObservationType
Whether to return a "date" or the number of "days".
Examples
# \donttest{
cdm <- mockPatientProfiles()
cdm$cohort1 %>%
addFutureObservation()
#> # Source: table<og_112_1715898457> [10 x 5]
#> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 2 7 1985-12-07 1999-01-25
#> 2 2 10 2054-04-17 2071-09-25
#> 3 1 9 2063-03-19 2087-08-23
#> 4 3 1 1929-11-07 1931-06-14
#> 5 2 8 2045-05-02 2082-02-20
#> 6 1 5 1967-01-22 2007-03-21
#> 7 3 2 1964-08-03 1969-11-18
#> 8 3 3 2037-12-16 2059-02-22
#> 9 2 4 1964-07-11 2072-07-08
#> 10 2 6 1940-09-12 2007-07-19
#> # ℹ 1 more variable: future_observation <int>
mockDisconnect(cdm = cdm)
# }