
Compute the number of days till the end of the observation period at a certain date
Source:R/addDemographics.R
addFutureObservation.RdCompute 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 demographics characteristics.
- futureObservationName
Future observation variable name.
- 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{
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
#> Warning: There are observation period end dates after the current date: 2026-04-06
#> ℹ The latest max observation period end date found is 2031-09-29
cdm$cohort1 |>
addFutureObservation()
#> # Source: table<og_134_1775495306> [?? x 5]
#> # Database: DuckDB 1.5.1 [unknown@Linux 6.17.0-1008-azure:R 4.5.3/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 2 4 1955-12-31 1964-06-24
#> 2 2 7 1939-10-15 1941-02-17
#> 3 3 5 1930-12-25 1938-07-18
#> 4 3 9 1951-01-18 1951-06-08
#> 5 3 3 1944-03-18 1950-04-22
#> 6 3 2 1977-09-21 2001-06-27
#> 7 2 6 2008-12-18 2009-06-01
#> 8 2 1 1984-05-15 2003-01-02
#> 9 1 8 2000-03-05 2018-01-07
#> 10 2 10 1916-08-02 1916-08-02
#> # ℹ 1 more variable: future_observation <int>
# }