Description Usage Arguments Value Examples
Update the metadata table of a dataset. The function will identify variable columns in df for which rows are missing in meta_tbl and append new rows for each. It will also remove any deprecated rows which do not match columns in the dataset.
1 2 | mt_update_factors(df, meta_tbl, factor_cols = NULL, sep = ";",
overwrite = F)
|
df |
a dataframe or tibble to which the metadata table relates to |
meta_tbl |
a metadata table associated with df |
factor_cols |
character string or vector of names of columns containing factors (will only apply to new columns) |
sep |
separator used to separate codes and definitions for each level in the metadata table (must be the same used throughout meta_tbl) |
overwrite |
logical. Whether to overwrite already existing metadata entries |
an updated meta_tbl with rows added for new df columns and any deprecated rows trimmed.
1 2 3 4 5 6 7 8 9 10 | ## Not run:
library(gapminder)
df <- gapminder::gapminder
meta_tbl <- readr::read_csv(system.file("extdata", "gapminder_meta.csv", package = "metadatar"))
# update metadata for factor columns from levels
mt_update_factors(df, meta_tbl, overwrite = F)
# update metadata for columns indicated as factors in the metadata table
mt_update_factors(df, meta_tbl, factor_cols = get_factors_meta(meta_tbl), overwrite = F)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.