Skip to contents

Write data and data dictionaries to files

Usage

writeToFiles(
  all_data,
  data_dir = here::here("data", "final"),
  dictionary_dir = here::here("data", "dictionary"),
  dictionary_filenames = c(tables = "data_dictionary_tables.txt", attributes =
    "data_dictionary_attributes.txt", categories = "data_dictionary_categories.txt"),
  lookup_dir = NA,
  verbose = FALSE,
  removeColumns = TRUE,
  cols_to_remove = c("CreationDate", "Creator", "EditDate", "Editor"),
  missing_value_dict = hash::hash(keys = c("string", "integer", "decimal", "datetime"),
    values = c("N/D", "-999", "-999", ""))
)

Arguments

all_data

Output of fetchRawData()

data_dir

Folder to store data csv's in

dictionary_dir

Folder to store data dictionaries in

dictionary_filenames

Named list with names c("tables", "attributes", "categories") indicating what to name the tables, attributes, and categories data dictionaries. You are encouraged to keep the default names unless you have a good reason to change them.

lookup_dir

Optional folder to store lookup tables in. If left as NA, lookups won't be exported.

verbose

Output feedback to console?

removeColumns

Should columns be removed?

cols_to_remove

Columns that should be removed, c("Editor", "Creator") is the default because they can contain personally identifiable information

missing_value_dict

a dictionary containing key-value pairs where the key is the attribute class and the value is the code for a missing value