
Indicate if a certain record is within the observation period
Source:R/addDemographics.R
addInObservation.Rd
Indicate 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-09-13
#> ℹ The latest max observation period end date found is 2025-12-29
cdm$cohort1 |>
addInObservation()
#> # Source: table<og_116_1757798548> [?? x 5]
#> # Database: DuckDB 1.3.3-dev231 [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 2 8 1943-04-01 1954-09-25
#> 2 3 6 2006-09-24 2018-06-21
#> 3 3 5 1978-11-28 1995-09-30
#> 4 3 10 1985-09-17 2011-06-26
#> 5 2 3 1926-09-04 1938-07-11
#> 6 1 7 1937-07-19 1946-02-20
#> 7 2 4 1926-01-17 1936-01-09
#> 8 3 1 1943-05-10 1949-05-27
#> 9 3 9 1983-05-29 1986-08-11
#> 10 1 2 1912-12-27 1917-05-23
#> # ℹ 1 more variable: in_observation <int>
# }