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"
)
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.
Examples
# \donttest{
cdm <- mockPatientProfiles()
cdm$cohort1 %>%
addInObservation()
#> # Source: table<og_114_1715898459> [10 x 5]
#> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 2 5 1946-01-05 2053-03-30
#> 2 1 2 2109-04-20 2177-09-29
#> 3 3 6 2083-06-17 2113-06-04
#> 4 1 10 2058-04-05 2059-09-05
#> 5 1 3 1949-12-11 2008-11-15
#> 6 2 1 2065-01-29 2099-05-30
#> 7 1 4 2050-05-30 2095-05-15
#> 8 3 9 1965-06-15 2053-03-01
#> 9 2 8 1957-07-26 1967-02-14
#> 10 1 7 1963-11-29 2065-12-09
#> # ℹ 1 more variable: in_observation <dbl>
mockDisconnect(cdm = cdm)
# }