map_values: Maps elements using a names list

Description Usage Arguments Value Examples

View source: R/map_values.R

Description

Given an array and a named list, maps values from the array to the right hand side of the named list.

Usage

1
map_values(x, map, if_null = NULL)

Arguments

x

Array

map

Named list

if_null

Value to use if not present in map, if if_null == NULL, then the missing values will be omitted.

Value

array of mapped values

Examples

1
2
3
4
x <- c(2, 2, 1, 2, 1, 3, 4)
map <- list('1' = 'one', '2' = 'two', '2' = 'three')

new_values <- map_values(x, map)

Beachnad/dbr documentation built on Nov. 6, 2019, 8:07 p.m.