
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 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{
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addFutureObservation()
#> # Source: table<og_121_1761733688> [?? x 5]
#> # Database: DuckDB 1.4.1 [unknown@Linux 6.11.0-1018-azure:R 4.5.1/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 3 6 1930-02-21 1931-10-25
#> 2 1 3 1924-05-17 1929-06-16
#> 3 1 9 2004-08-22 2008-07-31
#> 4 1 7 1930-12-01 1940-10-30
#> 5 3 5 1916-04-27 1923-06-04
#> 6 3 10 1971-12-18 1977-09-15
#> 7 3 4 1973-04-29 1978-07-19
#> 8 1 1 1939-05-06 1940-01-27
#> 9 1 2 1964-01-05 1964-08-14
#> 10 1 8 1949-10-15 1957-07-07
#> # ℹ 1 more variable: future_observation <int>
# }