Lists each categorical value a dataset has that is not an allowed value of its trait in traits.yml, and was therefore moved to excluded_data with the error "Unsupported trait value". The result is laid out as a table of substitutions with replace empty: fill in replace for each value, in R or a spreadsheet, and add them to the dataset's metadata.yml with metadata_add_substitutions_table(x, "dataset_id", "trait_name", "find", "replace").

dataset_check_categorical_substitutions(database, dataset_ids = NULL)

Arguments

database

Compiled database object, e.g. austraits

dataset_ids

dataset_id's to check. The default, NULL, lists the values for every dataset in the database.

Value

Tibble with one row per dataset, trait and unsupported value, with columns dataset_id, trait_name, find, replace (empty), n_records, the number of records excluded with that value, and unsupported, the words in find that are not allowed values of the trait.

Details

The values are as the build left them, after the dataset's existing substitutions and the synonyms declared in traits.yml were applied, and lower-cased, as find is matched. A value holding several space-separated values is excluded whole when any one of them is not allowed; unsupported lists which, since a single match: word substitution can fix that word wherever it occurs (see metadata_add_substitution()).

Examples

if (FALSE) { # \dontrun{
substitutions <- dataset_check_categorical_substitutions(austraits, "Test_2025")
# ... fill in `replace`, then
metadata_add_substitutions_table(substitutions, "dataset_id", "trait_name", "find", "replace")
} # }