named_map_builder: Named map builder.

Description Usage Arguments Value See Also Examples

View source: R/namedMapBuilder.R

Description

Set names of right-argument to be left-argument, and return right argument. Called from := operator.

Usage

1
2
3
4
5
named_map_builder(names, values)

":="(names, values)

names %:=% values

Arguments

names

names to set.

values

values to assign names to (and return).

Value

values with names set.

See Also

lambda, defineLambda, makeFunction_se

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
c('a' := '4', 'b' := '5')
# equivalent to: c(a = '4', b = '5')

c('a', 'b') := c('1', '2')
# equivalent to: c(a = '1', b = '2')

# the important example
name <- 'a'
name := '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)

f <- ~x := x^2
f(7)

f <- x := { sqrt(x) }
f(7)

WinVector/wrapr documentation built on Aug. 15, 2018, 4:04 p.m.