
Indicate if a certain record is within the observation period
Source:R/addDemographics.R
addInObservation.RdIndicate if a certain record is within the observation period
Usage
addInObservation(
x,
indexDate = "cohort_start_date",
window = c(0, 0),
completeInterval = FALSE,
nameStyle = "in_observation",
name = NULL
)Arguments
- x
Table with individuals in the cdm.
- indexDate
Variable in x that contains the date to compute the observation flag.
- window
window to consider events of.
- completeInterval
If the individuals are in observation for the full window.
- nameStyle
Name of the new columns to create, it must contain "window_name" if multiple windows are provided.
- 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: 2025-10-29
#> ℹ The latest max observation period end date found is 2026-07-08
cdm$cohort1 |>
addInObservation()
#> # Source: table<og_123_1761733693> [?? 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 1 5 1944-03-21 1946-06-11
#> 2 1 1 1926-07-02 1935-08-11
#> 3 1 10 2005-07-26 2006-02-23
#> 4 2 6 1909-02-11 1916-12-19
#> 5 3 8 1938-12-28 1939-06-21
#> 6 1 4 1928-06-17 1931-01-31
#> 7 1 3 1953-12-26 1956-11-11
#> 8 2 2 1979-06-26 1982-03-26
#> 9 2 7 1925-07-11 1933-03-23
#> 10 2 9 1977-11-27 2001-02-05
#> # ℹ 1 more variable: in_observation <int>
# }