
Compute demographic characteristics at a certain date
Source:R/addDemographics.R
addDemographics.Rd
Compute 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,
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.
- 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()
cdm$cohort1 |>
addDemographics()
#> # Source: table<og_116_1740755709> [?? x 8]
#> # Database: DuckDB v1.2.0 [unknown@Linux 6.8.0-1021-azure:R 4.4.2/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date age sex
#> <int> <int> <date> <date> <int> <chr>
#> 1 1 1 1937-09-05 1938-11-17 6 Fema…
#> 2 2 2 1965-03-06 1967-02-17 9 Male
#> 3 2 3 1932-03-21 1933-05-25 8 Male
#> 4 1 4 1963-09-11 1969-05-01 18 Male
#> 5 1 5 1924-07-28 1924-12-25 14 Fema…
#> 6 1 6 1981-12-13 1983-09-01 27 Fema…
#> 7 1 7 1940-01-06 1942-05-22 3 Male
#> 8 2 8 1956-05-01 1957-06-05 9 Male
#> 9 3 9 1911-04-01 1943-03-10 1 Fema…
#> 10 1 10 1990-08-22 1990-09-25 52 Male
#> # ℹ 2 more variables: prior_observation <int>, future_observation <int>
mockDisconnect(cdm = cdm)
# }