
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",
name = NULL
)
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".
- name
Name of the new table, if NULL a temporary table is returned.
Examples
# \donttest{
cdm <- mockPatientProfiles()
cdm$cohort1 |>
addFutureObservation()
#> # A tibble: 10 × 5
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> * <int> <int> <date> <date>
#> 1 1 6 1916-08-06 1919-03-04
#> 2 1 3 1957-04-02 1978-12-06
#> 3 1 10 1947-05-14 1952-11-01
#> 4 1 8 1970-11-27 1986-12-26
#> 5 1 1 1962-08-30 1977-08-26
#> 6 3 2 1914-03-28 1942-05-12
#> 7 1 5 1966-01-22 1968-05-01
#> 8 1 9 1938-06-25 1957-11-02
#> 9 3 7 1956-04-13 1966-05-17
#> 10 2 4 1939-08-19 1939-11-18
#> # ℹ 1 more variable: future_observation <int>
mockDisconnect(cdm = cdm)
# }