Creates a named vector that maps the values of two variables associated with taxa in a taxonomy() or taxmap() object. Both values must be named by taxon ids.

obj$map_data(from, to, warn = TRUE)
map_data(obj, from, to, warn = TRUE)

Arguments

obj

The taxonomy() or taxmap() object.

from

The value used to name the output. There will be one output value for each value in from. Any variable that appears in all_names() can be used as if it was a variable on its own.

to

The value returned in the output. Any variable that appears in all_names() can be used as if it was a variable on its own.

warn

If TRUE, issue a warning if there are multiple unique values of to for each value of from.

Value

A vector of to values named by values in from.

See also

Examples

# Mapping between two variables in `all_names(ex_taxmap)` map_data(ex_taxmap, from = taxon_names, to = n_legs > 0)
#> Mammalia Plantae Felidae Notoryctidae Hominidae Solanaceae #> NA NA NA NA NA NA #> Panthera Felis Notoryctes homo Solanum tigris #> NA NA NA NA NA TRUE #> catus typhlops sapiens lycopersicum tuberosum #> TRUE TRUE TRUE FALSE FALSE
# Mapping with external variables x = c("d" = "looks like a cat", "h" = "big scary cats", "i" = "smaller cats", "m" = "might eat you", "n" = "Meow! (Feed me!)") map_data(ex_taxmap, from = taxon_names, to = x)
#> Error in rlang::eval_tidy(rlang::enquo(unparsed), data = data_used): object 'x' not found