EVOLUTION-MANAGER
Edit File: compose.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Compose multiple functions</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for compose {purrr}"><tr><td>compose {purrr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Compose multiple functions</h2> <h3>Description</h3> <p>Compose multiple functions </p> <h3>Usage</h3> <pre> compose(..., .dir = c("backward", "forward")) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>...</code></td> <td> <p>Functions to apply in order (from right to left by default). Formulas are converted to functions in the usual way. </p> <p>These dots support <a href="../../rlang/html/list2.html">tidy dots</a> features. In particular, if your functions are stored in a list, you can splice that in with <code style="white-space: pre;">!!!</code>.</p> </td></tr> <tr valign="top"><td><code>.dir</code></td> <td> <p>If <code>"backward"</code> (the default), the functions are called in the reverse order, from right to left, as is conventional in mathematics. If <code>"forward"</code>, they are called from left to right.</p> </td></tr> </table> <h3>Value</h3> <p>A function </p> <h3>Examples</h3> <pre> not_null <- compose(`!`, is.null) not_null(4) not_null(NULL) add1 <- function(x) x + 1 compose(add1, add1)(8) # You can use the formula shortcut for functions: fn <- compose(~ paste(.x, "foo"), ~ paste(.x, "bar")) fn("input") # Lists of functions can be spliced with !!! fns <- list( function(x) paste(x, "foo"), ~ paste(.x, "bar") ) fn <- compose(!!!fns) fn("input") </pre> <hr /><div style="text-align: center;">[Package <em>purrr</em> version 0.3.4 <a href="00Index.html">Index</a>]</div> </body></html>