Map names from one software to another. The function replaces elements
in the input vector x with their corresponding values in the mapping if a
match is found. If an element in x does not have a corresponding mapping,
it is returned unchanged with a warning.
Usage
translate(
x = character(),
mapping = NULL,
nomatch = "original",
warning = TRUE
)Arguments
- x
charactervector of names to be translated.- mapping
A named
charactervector that defines the mapping for translation. The names of the vector should be the original names and the values should be the translated names.- nomatch
character(1)defining the value to be returned if a value inxcan not be translated. The defaultnomatch = "original"returns the original value inx, while any other value fornomatchwould report that value instead (e.g.nomatch = NA_character_would return anNAfor each value that can not be translated).- warning
logical(1)whether a warning should be reported if values inxcan not be translated.
See also
Other name translation functions:
guessSource(),
nameMapping(),
softwareMapping(),
softwareMappingSchema()
Examples
## MS-Dial names
x <- c("Average Rt(min)", "Alignment ID", "Average Mz")
map_vec <- nameMapping(from = "MS-Dial", to = "mzTab-M")
translate(x, mapping = map_vec)
#> Average Rt(min) Alignment ID
#> "retention_time_in_seconds" "SMF_ID"
#> Average Mz
#> "exp_mass_to_charge"
