util_separate_and_sort: For a vector x in which individual cell may have multiple values (separated by 'sep'), put the values within each cell in order and drop any value repeated within a cell.

util_separate_and_sort(x, sep = " ", order = "alphabetical")

Arguments

x

An individual cell with multiple values

sep

A separator, a whitespace is the default

order

"alphabetical" (the default) or "input_order"

Value

A vector of records, each with its values in the requested order and without repeats

Details

With order = "alphabetical" the values are sorted, so tree shrub and shrub tree both become shrub tree. With order = "input_order" they keep the order they were given in, so the first value can carry meaning, and only the repeats are dropped (tree shrub tree becomes tree shrub). Which one a build uses is set by trait_value_term_order in the database's config/metadata.yml; see util_trait_value_term_order().

Examples

if (FALSE) { # \dontrun{
util_separate_and_sort("z y x")
util_separate_and_sort("z y x y", order = "input_order")
} # }