Convert an ODK template to the OCA data sharing dictionary standard
Source:R/dict_from_odk.R
dict_from_odk.Rd
Convert an ODK template to the OCA data sharing dictionary standard
Arguments
- survey
A data.frame reflecting the 'survey' sheet within an ODK template
- choices
A data.frame reflecting the 'choices' sheet within an ODK template
- col_labels
(Optional) Name of the column found in both sheets 'survey' and 'choices' giving variable labels, e.g. "label::English". Defaults to
NULL
in which case the first column starting with prefix "label" is used for the label column.
Value
A tibble
-style data frame representing a data dictionary
formatted to the OCA data sharing standard
Examples
path_data <- system.file("extdata", package = "datadict")
path_odk_template <- file.path(path_data, "WHOVA2016_v1_5_3_ODK.xlsx")
odk_survey <- readxl::read_xlsx(path_odk_template, sheet = "survey")
odk_choices <- readxl::read_xlsx(path_odk_template, sheet = "choices")
dict_from_odk(odk_survey, odk_choices)
#> # A tibble: 593 × 17
#> variable_name short_label type choices origin status indirect_identifier
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Id10002 Is this a regi… Code… high, … origi… shared NA
#> 2 Id10003 Is this a regi… Code… high, … origi… shared NA
#> 3 Id10004 During which s… Code… wet, W… origi… shared NA
#> 4 Id10007 What is the na… Free… NA origi… shared NA
#> 5 Id10007a What is the se… Code… female… origi… shared NA
#> 6 Id10008 What is your/t… Code… parent… origi… shared NA
#> 7 Id10009 Did you/the re… Code… yes, Y… origi… shared NA
#> 8 Id10010 Name of VA int… Free… NA origi… shared NA
#> 9 Id10010a Age of VA inte… Nume… NA origi… shared NA
#> 10 Id10010b Sex of VA inte… Code… female… origi… shared NA
#> # ℹ 583 more rows
#> # ℹ 10 more variables: hint_english <chr>, relevant <chr>, required <chr>,
#> # notes <lgl>, appearance <chr>, calculation <chr>, default <lgl>,
#> # constraint <chr>, constraint_message_english <chr>, read_only <lgl>