Merges one-time data (non-longitudinal) into the main skeleton data structure. This function is used for adding data that doesn't change over time, such as demographic information or baseline characteristics.
Value
The skeleton data.table is modified by reference with one-time data merged in. Columns from data that already exist in skeleton will be prefixed with "i."
See also
create_skeleton for creating the skeleton structure,
add_annual for annual data,
make_lowercase_names for data preprocessing
Other data_integration:
add_annual(),
add_cods(),
add_diagnoses(),
add_icdo3s(),
add_operations(),
add_rx(),
add_snomed3s(),
add_snomedo10s()
Examples
# Load fake data
data("fake_person_ids", package = "swereg")
data("fake_demographics", package = "swereg")
swereg::make_lowercase_names(fake_demographics)
#> Found potential date columns: fodelseman. Consider adding them to date_columns parameter for automatic date parsing.
# Create skeleton
skeleton <- create_skeleton(fake_person_ids[1:5], "2020-01-01", "2020-12-31")
# Add demographic data
add_onetime(skeleton, fake_demographics, "lopnr")
#> id isoyear isoyearweek is_isoyear isoyearweeksun personyears fodelseman
#> <int> <int> <char> <lgcl> <Date> <num> <char>
#> 1: 1 1900 1900-** TRUE 1900-07-01 1.00000000 1959
#> 2: 1 1901 1901-** TRUE 1901-06-30 1.00000000 1959
#> 3: 1 1902 1902-** TRUE 1902-06-29 1.00000000 1959
#> 4: 1 1903 1903-** TRUE 1903-06-28 1.00000000 1959
#> 5: 1 1904 1904-** TRUE 1904-07-03 1.00000000 1959
#> ---
#> 866: 5 2020 2020-49 FALSE 2020-12-06 0.01913876 1954
#> 867: 5 2020 2020-50 FALSE 2020-12-13 0.01913876 1954
#> 868: 5 2020 2020-51 FALSE 2020-12-20 0.01913876 1954
#> 869: 5 2020 2020-52 FALSE 2020-12-27 0.01913876 1954
#> 870: 5 2020 2020-53 FALSE 2021-01-03 0.01913876 1954
#> doddatum
#> <char>
#> 1:
#> 2:
#> 3:
#> 4:
#> 5:
#> ---
#> 866:
#> 867:
#> 868:
#> 869:
#> 870:
# Check added variables
names(skeleton)
#> [1] "id" "isoyear" "isoyearweek" "is_isoyear"
#> [5] "isoyearweeksun" "personyears" "fodelseman" "doddatum"
