“named map builder” is an operator written as “:=”. Named map builder is a very simple bit of code that performs a very simple task: it adds names to vectors or lists (making them work more like maps).

Here are some examples:

library("wrapr")

'a' := 5
## a
## 5
c('a' := 5, 'b' := 6)
## a b
## 5 6
c('a', 'b') := c(5, 6)
## a b
## 5 6

The left-side argument of the := operator is called “the names”, and the right-side argument is called “the values”. The := operators returns the values with the names set to names.

A key use of the named map builder is the following:

key = 'keycode'
key := 'value'
## keycode
## "value"

Notice the value inside the variable key was used as the array name, this differs from what is easily done with R’s native c(key = 'value') style notation.

help(:=, package = 'wrapr')