Set names of right-argument to be left-argument, and return right argument. Has a special case for length-1 name sets. Called from := operator.

named_map_builder(names, values)

":="(names, values)

Arguments

names

names to set.

values

values to assign names to (and return).

Value

values with names set.

Examples

c('a' := '4', 'b' := '5')
#> a b #> "4" "5"
# equivalent to: c(a = '4', b = '5') c('a', 'b') := c('1', '2')
#> a b #> "1" "2"
# equivalent to: c(a = '1', b = '2') # the important example name <- 'a' name := '5'
#> a #> "5"
# equivalent to: c('a' = '5') # fn version: # applied when right side is {} # or when left side is of class formula. g <- x~y := { x + 3*y } g(1,100)
#> [1] 301
f <- ~x := x^2 f(7)
#> [1] 49