arrow: arrow function

Description Usage Arguments Value Examples

Description

express a function using javascript-style arrow function syntax

Usage

1
2
3
4
5
args %f% body

args %F% body

args %=>% body

Arguments

args

the arguments of the function expression. For multiple arguments, use a vector, 'c'.

body

the body of the function. If it contains operations or multiple lines, wrap it in brackets like an expression.

Value

a function

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
library(arrow)
greet_user <- c() %F% paste("hi", Sys.getenv("USER"))
greet_user()

scatter <- d %F% {
  s <- strsplit(d, "")[[1]]
  s[sample(length(s), length(s))]
}
sapply(month.name, scatter)

v <- c(a, b = 10, c = 10) %F% {a + b * c}
v(10)

## End(Not run)

mdequeljoe/fu documentation built on May 9, 2019, 8:18 a.m.