
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,
type = "numeric"
)Arguments
- x
A table containing individuals in a CDM reference.
- indexDate
Name of a date column in
x, or a single date to use for all rows, used as the reference date.- window
Window or windows of time relative to
indexDateto consider.- completeInterval
If
TRUE, individuals must be observed for the full requested interval.- nameStyle
Naming pattern for the added column or columns. It should include the required formatting variables. If more than one
tableNameis provided, it must include{table_name}.- name
Name of the new table. If
NULL, a temporary table is returned.- type
Type of the created column(s). Counts, days, age, and observation durations can be
"numeric"or"integer". Flag columns can also be"logical". Field columns can use"auto"to preserve the source type, or can be converted to"numeric","integer","logical", or"character".
Value
Cohort table with an added column assessing observation. Values are
1/TRUE in observation and 0/FALSE otherwise, according to type.
Examples
# \donttest{
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addInObservation()
#> # A query: ?? x 5
#> # Database: DuckDB 1.5.4 [unknown@Linux 6.17.0-1020-azure:R 4.6.1/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 1 8 1964-06-22 1965-02-05
#> 2 1 5 1946-06-10 1949-06-04
#> 3 3 4 1962-03-04 1966-07-21
#> 4 1 9 1932-02-17 1932-04-06
#> 5 2 6 1917-08-02 1924-06-04
#> 6 1 1 1931-10-03 1941-04-05
#> 7 2 3 1928-08-26 1929-05-31
#> 8 1 2 1968-06-27 1973-10-29
#> 9 2 10 1972-02-04 1973-12-24
#> 10 1 7 1938-03-17 1954-06-12
#> # ℹ 1 more variable: in_observation <dbl>
# }