
Compute demographic characteristics at a certain date
Source:R/addDemographics.R
addDemographics.RdCompute demographic characteristics at a certain date
Usage
addDemographics(
x,
indexDate = "cohort_start_date",
age = TRUE,
ageName = "age",
ageMissingMonth = 1,
ageMissingDay = 1,
ageImposeMonth = FALSE,
ageImposeDay = FALSE,
ageUnit = "years",
ageGroup = NULL,
missingAgeGroupValue = "None",
sex = TRUE,
sexName = "sex",
missingSexValue = "None",
priorObservation = TRUE,
priorObservationName = "prior_observation",
priorObservationType = "days",
futureObservation = TRUE,
futureObservationName = "future_observation",
futureObservationType = "days",
dateOfBirth = FALSE,
dateOfBirthName = "date_of_birth",
name = NULL
)Arguments
- x
Table with individuals in the cdm.
- indexDate
Variable in x that contains the date to compute the demographics characteristics.
- age
TRUE or FALSE. If TRUE, age will be calculated relative to indexDate.
- ageName
Age variable name.
- ageMissingMonth
Month of the year assigned to individuals with missing month of birth.
- ageMissingDay
day of the month assigned to individuals with missing day of birth.
- ageImposeMonth
TRUE or FALSE. Whether the month of the date of birth will be considered as missing for all the individuals.
- ageImposeDay
TRUE or FALSE. Whether the day of the date of birth will be considered as missing for all the individuals.
- ageUnit
Unit for age it can either be 'years', 'months' or 'days'.
- ageGroup
if not NULL, a list of ageGroup vectors.
- missingAgeGroupValue
Value to include if missing age.
- sex
TRUE or FALSE. If TRUE, sex will be identified.
- sexName
Sex variable name.
- missingSexValue
Value to include if missing sex.
- priorObservation
TRUE or FALSE. If TRUE, days of between the start of the current observation period and the indexDate will be calculated.
- priorObservationName
Prior observation variable name.
- priorObservationType
Whether to return a "date" or the number of "days".
- futureObservation
TRUE or FALSE. If TRUE, days between the indexDate and the end of the current observation period will be calculated.
- futureObservationName
Future observation variable name.
- futureObservationType
Whether to return a "date" or the number of "days".
- dateOfBirth
TRUE or FALSE, if true the date of birth will be return.
- dateOfBirthName
dateOfBirth column name.
- name
Name of the new table, if NULL a temporary table is returned.
Examples
# \donttest{
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addDemographics()
#> # Source: table<og_132_1775495299> [?? x 8]
#> # 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 age sex
#> <int> <int> <date> <date> <int> <chr>
#> 1 1 1 1935-04-13 1940-09-15 6 Male
#> 2 2 2 1946-03-18 1947-03-22 23 Male
#> 3 1 3 1962-02-25 1986-02-23 1 Fema…
#> 4 3 4 1942-02-14 1947-03-25 23 Male
#> 5 1 5 1960-01-25 1964-08-16 2 Fema…
#> 6 2 6 1973-01-12 1978-08-06 7 Fema…
#> 7 2 7 1979-07-25 1980-02-10 17 Male
#> 8 3 8 1928-05-26 1948-08-05 3 Male
#> 9 1 9 1953-10-01 1963-12-09 13 Male
#> 10 2 10 1956-12-16 1964-03-02 10 Male
#> # ℹ 2 more variables: prior_observation <int>, future_observation <int>
# }