
Create variable-level metadata from a survey dataset
Source:R/metadata_create.R
metadata_survey_create.RdExtract variable-level metadata from a survey dataset and return the result as a nested data frame.
Value
A nested data frame containing:
- filename
Original survey file name.
- id
Survey identifier.
- var_name_orig
Original variable name.
- class_orig
Imported storage class.
- var_label_orig
Original variable label.
- labels
List column of value labels.
- valid_labels
List column of non-missing value labels.
- na_labels
List column of user-defined missing labels.
- na_range
List column containing user-defined missing ranges.
- n_labels
Number of labelled categories.
- n_valid_labels
Number of non-missing categories.
- n_na_labels
Number of missing categories.
Details
The metadata table contains:
variable names and labels,
imported storage classes,
value labels,
user-defined missing values,
missing value ranges,
and summary counts of labelled categories.
For multiple surveys, use [metadata_create()], which applies `metadata_survey_create()` across a list of surveys or survey files.
See also
[metadata_create()], [create_variable_catalog()]
Other metadata functions:
create_codebook(),
is.crosswalk_table(),
metadata_create()
Examples
metadata_survey_create(
survey = read_rds(
system.file(
"examples",
"ZA7576.rds",
package = "retroharmonize"
)
)
)
#> filename id var_name_orig class_orig
#> 1 ZA7576.rds ZA7576 rowid character
#> 2 ZA7576.rds ZA7576 doi character
#> 3 ZA7576.rds ZA7576 version character
#> 4 ZA7576.rds ZA7576 uniqid numeric
#> 5 ZA7576.rds ZA7576 caseid numeric
#> 6 ZA7576.rds ZA7576 serialid numeric
#> 7 ZA7576.rds ZA7576 isocntry character
#> 8 ZA7576.rds ZA7576 p1 haven_labelled
#> 9 ZA7576.rds ZA7576 p2 haven_labelled
#> 10 ZA7576.rds ZA7576 p3 haven_labelled_spss
#> 11 ZA7576.rds ZA7576 p4 haven_labelled
#> 12 ZA7576.rds ZA7576 nuts haven_labelled
#> 13 ZA7576.rds ZA7576 d7 haven_labelled
#> 14 ZA7576.rds ZA7576 d8 haven_labelled
#> 15 ZA7576.rds ZA7576 d25 haven_labelled_spss
#> 16 ZA7576.rds ZA7576 d60 haven_labelled
#> 17 ZA7576.rds ZA7576 qa14_5 haven_labelled
#> 18 ZA7576.rds ZA7576 qa14_3 haven_labelled_spss
#> 19 ZA7576.rds ZA7576 qa14_2 haven_labelled_spss
#> 20 ZA7576.rds ZA7576 qa14_4 haven_labelled_spss
#> 21 ZA7576.rds ZA7576 qa14_1 haven_labelled_spss
#> 22 ZA7576.rds ZA7576 qa6a_5 haven_labelled_spss
#> 23 ZA7576.rds ZA7576 qa6a_10 haven_labelled_spss
#> 24 ZA7576.rds ZA7576 qa6b_2 haven_labelled_spss
#> 25 ZA7576.rds ZA7576 qa6a_3 haven_labelled_spss
#> 26 ZA7576.rds ZA7576 qa6a_1 haven_labelled_spss
#> 27 ZA7576.rds ZA7576 qa6b_4 haven_labelled_spss
#> 28 ZA7576.rds ZA7576 qa6a_8 haven_labelled_spss
#> 29 ZA7576.rds ZA7576 qa6a_9 haven_labelled_spss
#> 30 ZA7576.rds ZA7576 qa6a_4 haven_labelled_spss
#> 31 ZA7576.rds ZA7576 qa6a_2 haven_labelled_spss
#> 32 ZA7576.rds ZA7576 qa6b_1 haven_labelled_spss
#> 33 ZA7576.rds ZA7576 qa6a_6 haven_labelled_spss
#> 34 ZA7576.rds ZA7576 qa6a_7 haven_labelled_spss
#> 35 ZA7576.rds ZA7576 qa6a_11 haven_labelled_spss
#> 36 ZA7576.rds ZA7576 qa6b_3 haven_labelled_spss
#> 37 ZA7576.rds ZA7576 qd6.1 haven_labelled_spss
#> 38 ZA7576.rds ZA7576 qd6.2 haven_labelled_spss
#> 39 ZA7576.rds ZA7576 qd6.3 haven_labelled_spss
#> 40 ZA7576.rds ZA7576 qd6.4 haven_labelled_spss
#> 41 ZA7576.rds ZA7576 qd6.5 haven_labelled_spss
#> 42 ZA7576.rds ZA7576 qd6.6 haven_labelled_spss
#> 43 ZA7576.rds ZA7576 qd6.7 haven_labelled_spss
#> 44 ZA7576.rds ZA7576 qd6.8 haven_labelled_spss
#> 45 ZA7576.rds ZA7576 qd6.9 haven_labelled_spss
#> 46 ZA7576.rds ZA7576 qd6.10 haven_labelled_spss
#> 47 ZA7576.rds ZA7576 qd6.11 haven_labelled_spss
#> 48 ZA7576.rds ZA7576 qd6.12 haven_labelled_spss
#> 49 ZA7576.rds ZA7576 qd6.13 haven_labelled_spss
#> 50 ZA7576.rds ZA7576 qd6.14 haven_labelled_spss
#> 51 ZA7576.rds ZA7576 qg1b haven_labelled_spss
#> 52 ZA7576.rds ZA7576 qg8 haven_labelled_spss
#> 53 ZA7576.rds ZA7576 w1 numeric
#> 54 ZA7576.rds ZA7576 w3 numeric
#> 55 ZA7576.rds ZA7576 wex numeric
#> var_label_orig
#> 1 unique_identifier_in_za_7576
#> 2 digital_object_identifier
#> 3 gesis_archive_version_and_date
#> 4 unique_respondent_id_caseid_by_kantar_country_code
#> 5 kantar_case_id_country_specific
#> 6 serial_case_id_appointed_by_kantar
#> 7 country_code_iso_3166
#> 8 date_of_interview
#> 9 time_of_interview
#> 10 duration_of_interview
#> 11 n_of_persons_present_during_interview
#> 12 region_nuts_codes
#> 13 marital_status
#> 14 age_education
#> 15 type_of_community
#> 16 difficulties_paying_bills_last_year
#> 17 council_of_the_eu_trust
#> 18 european_central_bank_trust
#> 19 european_commission_trust
#> 20 european_council_trust
#> 21 european_parliament_trust
#> 22 trust_in_institutions_army
#> 23 trust_in_institutions_european_union
#> 24 trust_in_institutions_european_union_tcc
#> 25 trust_in_institutions_justice_legal_system
#> 26 trust_in_institutions_media
#> 27 trust_in_institutions_media_tcc
#> 28 trust_in_institutions_national_government
#> 29 trust_in_institutions_national_parliament
#> 30 trust_in_institutions_police
#> 31 trust_in_institutions_political_parties
#> 32 trust_in_institutions_political_parties_tcc
#> 33 trust_in_institutions_public_administration
#> 34 trust_in_institutions_reg_local_public_authorities
#> 35 trust_in_institutions_united_nations
#> 36 trust_in_institutions_united_nations_tcc
#> 37 important_values_pers_rule_of_law
#> 38 important_values_pers_respect_human_life
#> 39 important_values_pers_human_rights
#> 40 important_values_pers_individual_freedom
#> 41 important_values_pers_democracy
#> 42 important_values_pers_peace
#> 43 important_values_pers_equality
#> 44 important_values_pers_solidarity
#> 45 important_values_pers_tolerance
#> 46 important_values_pers_religion
#> 47 important_values_pers_self_fulfilment
#> 48 important_values_pers_respect_for_cultures
#> 49 important_values_pers_none_spont
#> 50 important_values_pers_dk
#> 51 voters_when_decided_to_vote
#> 52 non_voters_when_decided_not_to_vote
#> 53 weight_result_from_target_redressment
#> 54 weight_germany
#> 55 weight_extrapolated_population_aged_15_plus
#> labels
#> 1 NA
#> 2 NA
#> 3 NA
#> 4 NA
#> 5 NA
#> 6 NA
#> 7 NA
#> 8 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21
#> 9 1, 2, 3, 4, 5, 6, 8
#> 10 1, 363, 377, 383, 388, 392, 409, 414, 416, 452, 454, 482, 531, 537, 543, 548, 555, 604, 613, 627, 656, 709, 738, 744, 747, 999
#> 11 1, 2, 3, 4, 5
#> 12 ME, RS, MT, LU, CY, DE1, DE2, DE3, DE4, DE5, DE6, DE7, DE8, DE9, FR9, DEA, DEB, DEC, UKC, ITC, DED, UKD, DEE, UKE, DEF, UKF, ITF, DEG, UKG, ITG, UKH, ITH, UKI, ITI, UKJ, UKK, UKL, UKM, UKN, BE10, FR10, TR10, HU10, PT20, EL30, FR30, ES30, PT30, ES70, TR90, DK01, SK01, CZ01, SE11, EL11, NL11, PL11, RO11, ES11, AT11, PT11, BE21, SE21, EL21, NL21, PL21, RO21, FR21, TR21, ES21, AT21, HU21, BE31, SE31, BG31, NL31, PL31, RO31, TR31, AT31, HU31, BG41, EL41, NL41, PL41, RO41, FR41, TR41, ES41, PL51, FR51, TR51, ES51, PL61, FR61, TR61, ES61, FR71, TR71, FR81, TR81, TRA1, TRB1, TRC1, DK02, SK02, CZ02, SE12, EL12, NL12, PL12, RO12, ES12, AT12, BE22, SE22, EL22, NL22, PL22, RO22, FR22, TR22, ES22, AT22, HU22, BE32, SE32, BG32, NL32, PL32, RO32, TR32, AT32, HU32, BG42, EL42, NL42, PL42, RO42, FR42, TR42, ES42, PL52, FR52, TR52, ES52, PL62, FR62, TR62, ES62, FR72, TR72, FR82, TR82, TRA2, TRB2, TRC2, DK03, SK03, CZ03, EL13, NL13, ES13, AT13, BE23, SE23, EL23, NL23, FR23, ES23, HU23, BE33, SE33, BG33, NL33, PL33, TR33, AT33, HU33, EL43, PL43, FR43, ES43, FR53, ES53, PL63, FR63, TR63, ES63, FR83, TR83, TRC3, DK04, SK04, CZ04, EL14, BE24, EL24, FR24, ES24, BE34, BG34, NL34, PL34, AT34, ES64, DK05, CZ05, PT15, BE25, EL25, FR25, BE35, CZ06, PT16, FR26, CZ07, PT17, CZ08, PT18, FI19, FI1B, FI1C, FI1D, FI200, EE001, MK001, LT001, IE011, SI011, AL011, IE021, SI021, AL021, AL031, HR031, HR041, MK002, LT002, IE012, SI012, AL012, IE022, SI022, AL022, AL032, HR032, HR042, MK003, LT003, LV003, IE013, SI013, AL013, IE023, SI023, AL033, HR033, HR043, EE004, MK004, LT004, SI014, AL014, IE024, SI024, AL034, HR034, HR044, MK005, LT005, LV005, SI015, AL015, IE025, AL035, HR035, HR045, EE006, MK006, LT006, LV006, SI016, HR036, HR046, EE007, MK007, LT007, LV007, SI017, HR037, HR047, EE008, MK008, LT008, LV008, SI018, HR048, LT009, LV009, HR049, LT00A, HR04A, HR04B, HR04C, CYTCC, HR04D, HR04E
#> 13 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 97
#> 14 0, 2, 89, 97, 98, 99
#> 15 1, 2, 3, 8
#> 16 1, 2, 3, 7
#> 17 1, 2, 3, 9
#> 18 1, 2, 3, 9
#> 19 1, 2, 3, 9
#> 20 1, 2, 3, 9
#> 21 1, 2, 3, 9
#> 22 1, 2, 3, 9
#> 23 1, 2, 3, 9
#> 24 1, 2, 3, 9
#> 25 1, 2, 3, 9
#> 26 1, 2, 3, 9
#> 27 1, 2, 3, 9
#> 28 1, 2, 3, 9
#> 29 1, 2, 3, 9
#> 30 1, 2, 3, 9
#> 31 1, 2, 3, 9
#> 32 1, 2, 3, 9
#> 33 1, 2, 3, 9
#> 34 1, 2, 3, 9
#> 35 1, 2, 3, 9
#> 36 1, 2, 3, 9
#> 37 0, 1, 9
#> 38 0, 1, 9
#> 39 0, 1, 9
#> 40 0, 1, 9
#> 41 0, 1, 9
#> 42 0, 1, 9
#> 43 0, 1, 9
#> 44 0, 1, 9
#> 45 0, 1, 9
#> 46 0, 1, 9
#> 47 0, 1, 9
#> 48 0, 1, 9
#> 49 0, 1, 9
#> 50 0, 1, 9
#> 51 1, 2, 3, 4, 5, 6, 9, 99
#> 52 1, 2, 3, 4, 5, 6, 9, 99
#> 53 NA
#> 54 NA
#> 55 NA
#> valid_labels
#> 1 NA
#> 2 NA
#> 3 NA
#> 4 NA
#> 5 NA
#> 6 NA
#> 7 NA
#> 8 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21
#> 9 1, 2, 3, 4, 5, 6, 8
#> 10 1, 363, 377, 383, 388, 392, 409, 414, 416, 452, 454, 482, 531, 537, 543, 548, 555, 604, 613, 627, 656, 709, 738, 744, 747
#> 11 1, 2, 3, 4, 5
#> 12 ME, RS, MT, LU, CY, DE1, DE2, DE3, DE4, DE5, DE6, DE7, DE8, DE9, FR9, DEA, DEB, DEC, UKC, ITC, DED, UKD, DEE, UKE, DEF, UKF, ITF, DEG, UKG, ITG, UKH, ITH, UKI, ITI, UKJ, UKK, UKL, UKM, UKN, BE10, FR10, TR10, HU10, PT20, EL30, FR30, ES30, PT30, ES70, TR90, DK01, SK01, CZ01, SE11, EL11, NL11, PL11, RO11, ES11, AT11, PT11, BE21, SE21, EL21, NL21, PL21, RO21, FR21, TR21, ES21, AT21, HU21, BE31, SE31, BG31, NL31, PL31, RO31, TR31, AT31, HU31, BG41, EL41, NL41, PL41, RO41, FR41, TR41, ES41, PL51, FR51, TR51, ES51, PL61, FR61, TR61, ES61, FR71, TR71, FR81, TR81, TRA1, TRB1, TRC1, DK02, SK02, CZ02, SE12, EL12, NL12, PL12, RO12, ES12, AT12, BE22, SE22, EL22, NL22, PL22, RO22, FR22, TR22, ES22, AT22, HU22, BE32, SE32, BG32, NL32, PL32, RO32, TR32, AT32, HU32, BG42, EL42, NL42, PL42, RO42, FR42, TR42, ES42, PL52, FR52, TR52, ES52, PL62, FR62, TR62, ES62, FR72, TR72, FR82, TR82, TRA2, TRB2, TRC2, DK03, SK03, CZ03, EL13, NL13, ES13, AT13, BE23, SE23, EL23, NL23, FR23, ES23, HU23, BE33, SE33, BG33, NL33, PL33, TR33, AT33, HU33, EL43, PL43, FR43, ES43, FR53, ES53, PL63, FR63, TR63, ES63, FR83, TR83, TRC3, DK04, SK04, CZ04, EL14, BE24, EL24, FR24, ES24, BE34, BG34, NL34, PL34, AT34, ES64, DK05, CZ05, PT15, BE25, EL25, FR25, BE35, CZ06, PT16, FR26, CZ07, PT17, CZ08, PT18, FI19, FI1B, FI1C, FI1D, FI200, EE001, MK001, LT001, IE011, SI011, AL011, IE021, SI021, AL021, AL031, HR031, HR041, MK002, LT002, IE012, SI012, AL012, IE022, SI022, AL022, AL032, HR032, HR042, MK003, LT003, LV003, IE013, SI013, AL013, IE023, SI023, AL033, HR033, HR043, EE004, MK004, LT004, SI014, AL014, IE024, SI024, AL034, HR034, HR044, MK005, LT005, LV005, SI015, AL015, IE025, AL035, HR035, HR045, EE006, MK006, LT006, LV006, SI016, HR036, HR046, EE007, MK007, LT007, LV007, SI017, HR037, HR047, EE008, MK008, LT008, LV008, SI018, HR048, LT009, LV009, HR049, LT00A, HR04A, HR04B, HR04C, CYTCC, HR04D, HR04E
#> 13 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 97
#> 14 0, 2, 89, 97, 98, 99
#> 15 1, 2, 3
#> 16 1, 2, 3, 7
#> 17 1, 2, 3, 9
#> 18 1, 2, 3
#> 19 1, 2, 3
#> 20 1, 2, 3
#> 21 1, 2, 3
#> 22 1, 2, 3
#> 23 1, 2, 3
#> 24 1, 2, 3
#> 25 1, 2, 3
#> 26 1, 2, 3
#> 27 1, 2, 3
#> 28 1, 2, 3
#> 29 1, 2, 3
#> 30 1, 2, 3
#> 31 1, 2, 3
#> 32 1, 2, 3
#> 33 1, 2, 3
#> 34 1, 2, 3
#> 35 1, 2, 3
#> 36 1, 2, 3
#> 37 0, 1
#> 38 0, 1
#> 39 0, 1
#> 40 0, 1
#> 41 0, 1
#> 42 0, 1
#> 43 0, 1
#> 44 0, 1
#> 45 0, 1
#> 46 0, 1
#> 47 0, 1
#> 48 0, 1
#> 49 0, 1
#> 50 0, 1
#> 51 1, 2, 3, 4, 5, 6
#> 52 1, 2, 3, 4, 5, 6
#> 53 NA
#> 54 NA
#> 55 NA
#> na_labels na_range n_labels n_valid_labels n_na_labels
#> 1 NA NA 0 0 0
#> 2 NA NA 0 0 0
#> 3 NA NA 0 0 0
#> 4 NA NA 0 0 0
#> 5 NA NA 0 0 0
#> 6 NA NA 0 0 0
#> 7 NA NA 0 0 0
#> 8 NA 21 21 0
#> 9 NA 7 7 0
#> 10 999 NA 26 25 1
#> 11 NA 5 5 0
#> 12 NA 308 308 0
#> 13 NA 16 16 0
#> 14 NA 6 6 0
#> 15 8 NA 4 3 1
#> 16 NA 4 4 0
#> 17 NA 4 4 0
#> 18 9 NA 4 3 1
#> 19 9 NA 4 3 1
#> 20 9 NA 4 3 1
#> 21 9 NA 4 3 1
#> 22 9 NA 4 3 1
#> 23 9 NA 4 3 1
#> 24 9 NA 4 3 1
#> 25 9 NA 4 3 1
#> 26 9 NA 4 3 1
#> 27 9 NA 4 3 1
#> 28 9 NA 4 3 1
#> 29 9 NA 4 3 1
#> 30 9 NA 4 3 1
#> 31 9 NA 4 3 1
#> 32 9 NA 4 3 1
#> 33 9 NA 4 3 1
#> 34 9 NA 4 3 1
#> 35 9 NA 4 3 1
#> 36 9 NA 4 3 1
#> 37 9 NA 3 2 1
#> 38 9 NA 3 2 1
#> 39 9 NA 3 2 1
#> 40 9 NA 3 2 1
#> 41 9 NA 3 2 1
#> 42 9 NA 3 2 1
#> 43 9 NA 3 2 1
#> 44 9 NA 3 2 1
#> 45 9 NA 3 2 1
#> 46 9 NA 3 2 1
#> 47 9 NA 3 2 1
#> 48 9 NA 3 2 1
#> 49 9 NA 3 2 1
#> 50 9 NA 3 2 1
#> 51 9, 99 NA 8 6 2
#> 52 9, 99 NA 8 6 2
#> 53 NA NA 0 0 0
#> 54 NA NA 0 0 0
#> 55 NA NA 0 0 0