purrr draws inspiration from many related tools:
List operations defined in the Haskell prelude
Scala's list methods.
rlist, another R package to support working with lists. Similar goals but somewhat different philosophy.
However, the goal of purrr is not to try and simulate a purer functional programming language in R; we don't want to implement a second-class version of Haskell in R. The goal is to give you similar expressiveness to an FP language, while allowing you to write code that looks and works like R:
Instead of point free (tacit) style, we use the pipe,
%>%, to write code
that can be read from left to right.
Instead of currying, we use
... to pass in extra arguments.
Anonymous functions are verbose in R, so we provide two convenient shorthands.
For unary functions,
~ .x + 1 is equivalent to
function(.x) .x + 1.
For chains of transformations functions,
. %>% f() %>% g() is
function(.) . %>% f() %>% g() (this shortcut is provided
R is weakly typed, so we need
map variants that describe the output type
map_dbl(), etc) because don't the return type of
R has named arguments, so instead of providing different functions for
minor variations (e.g.
detectLast()) we use a named
.right. Type-stable functions are easy to reason about so
additional arguments will never change the type of the output.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.