update_dictionary() reads the data objects in data/ again and updates
data-raw/dictionary.csv to match them. Run it after the data changed:
a variable was added, removed or renamed, its type changed, or a data
object was added or removed.
What you wrote in the dictionary is kept. Rows are matched on file_name
and variable_name, and a matched row keeps its description and the value
of every other column, including columns you added yourself, such as
unit or allowed_values. Only variable_type is refreshed from the
data. A new variable gets a row with empty cells to fill in. The row of a
variable that no longer exists is removed, and the function names it.
A renamed variable or data object cannot be told from one removed and one
added, so what you wrote in the removed rows is printed for you to copy
into the new rows.
A dictionary in an older layout is brought to the washr layout first:
an unnamed index column and unnamed empty columns from a spreadsheet are
dropped, directory and file_name are derived from the data objects
when the file lacks them or holds placeholders (a variable that several
data objects carry gets one row per object), and a row whose variable no
data object carries stops the run with the variable named.
The five washr columns come first, in order; every other column keeps its place after them. The rows follow the data: data objects in alphabetical order, variables in the order of the data object. When nothing differs, the file is left untouched, so the function is safe to run again.
Value
The path of the dictionary file, invisibly. Error if there is no
dictionary yet, no tidy data, or the dictionary lacks the file_name or
variable_name column.
See also
Before: setup_dictionary(), which writes the dictionary the
first time. Next: setup_roxygen(), which regenerates the variable
table of the documentation from the dictionary.
Other setup functions:
setup_ci(),
setup_dictionary(),
setup_rawdata(),
setup_roxygen()
Examples
if (FALSE) { # \dontrun{
setup_dictionary()
# Later, after data_processing.R exported changed data
update_dictionary()
setup_roxygen()
} # }
