
Compute the number of days of prior observation in the current observation period at a certain date
Source:R/addDemographics.R
addPriorObservation.RdCompute 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 demographics characteristics.
- priorObservationName
Prior observation variable name.
- 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{
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addPriorObservation()
#> # Source: table<og_139_1775495324> [?? 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 3 1 1981-10-27 1990-02-28
#> 2 2 6 2001-02-25 2007-04-08
#> 3 1 8 1988-12-01 1989-04-10
#> 4 1 5 1971-08-14 1975-03-22
#> 5 2 2 1957-09-13 1985-10-01
#> 6 1 7 1973-05-25 1985-09-07
#> 7 2 10 1939-08-11 1948-11-23
#> 8 3 9 1936-05-24 1940-04-27
#> 9 3 4 1980-05-15 1993-02-09
#> 10 2 3 1935-04-02 1938-01-13
#> # ℹ 1 more variable: prior_observation <int>
# }