
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_116_1750280297> [?? x 5]
#> # Database: DuckDB v1.3.0 [unknown@Linux 6.11.0-1015-azure:R 4.5.1/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date
#> <int> <int> <date> <date>
#> 1 3 7 1997-03-31 1997-06-24
#> 2 1 5 1963-12-26 1967-05-15
#> 3 2 8 1945-12-06 1979-12-15
#> 4 1 10 1909-02-07 1924-01-03
#> 5 1 9 1987-04-20 2001-03-03
#> 6 2 2 2012-01-11 2018-05-01
#> 7 3 3 1944-04-23 1949-09-04
#> 8 3 6 1932-05-27 1932-09-24
#> 9 3 4 1932-08-17 1941-07-10
#> 10 1 1 1978-04-29 1981-05-19
#> # ℹ 1 more variable: prior_observation <int>
mockDisconnect(cdm = cdm)
# }