
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.
Value
cohort table with the added numeric column assessing observation (1 in observation, 0 not in observation).
Examples
# \donttest{
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addInObservation()
#> # Source: table<og_136_1775495312> [?? 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 1 3 1914-04-04 1916-08-22
#> 2 1 10 1926-01-20 1931-07-28
#> 3 3 9 1958-02-15 1959-09-15
#> 4 3 6 1970-09-17 1985-10-11
#> 5 2 8 1929-10-19 1931-11-07
#> 6 3 7 1924-04-28 1932-01-26
#> 7 3 1 1986-11-09 1988-04-11
#> 8 2 5 1974-11-05 1977-04-17
#> 9 2 4 1946-03-18 1954-10-25
#> 10 3 2 1981-06-09 1999-09-06
#> # ℹ 1 more variable: in_observation <int>
# }