Compute the number of days of prior observation in the current observation period at a certain date
Source:R/addDemographics.R
addPriorObservation.Rd
Compute the number of days of prior observation in the current observation period at a certain date
Usage
addPriorObservation(
x,
indexDate = "cohort_start_date",
priorObservationName = "prior_observation",
priorObservationType = "days",
name = NULL
)
Arguments
- x
Table with individuals in the cdm.
- indexDate
Variable in x that contains the date to compute the prior observation.
- priorObservationName
name of the new column to be added.
- priorObservationType
Whether to return a "date" or the number of "days".
- name
Name of the new table, if NULL a temporary table is returned.
Examples
# \donttest{
cdm <- mockPatientProfiles()
cdm$cohort1 %>%
addPriorObservation()
#> # Source: table<og_132_1730219864> [10 x 5]
#> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 1 1 1968-11-03 1971-01-10
#> 2 1 2 1948-01-28 1957-12-17
#> 3 2 3 1924-04-27 1932-10-04
#> 4 3 4 1916-10-19 1920-09-01
#> 5 2 5 1985-06-29 1987-12-31
#> 6 2 6 1993-04-29 1996-06-11
#> 7 3 7 1922-11-18 1949-08-28
#> 8 1 8 1977-08-06 1995-12-04
#> 9 1 9 1991-06-24 2005-05-09
#> 10 1 10 1948-02-23 1951-09-25
#> # ℹ 1 more variable: prior_observation <int>
mockDisconnect(cdm = cdm)
# }