EVOLUTION-MANAGER
Edit File: mapply.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: Apply a Function to Multiple List or Vector Arguments</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 mapply {base}"><tr><td>mapply {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Apply a Function to Multiple List or Vector Arguments</h2> <h3>Description</h3> <p><code>mapply</code> is a multivariate version of <code><a href="lapply.html">sapply</a></code>. <code>mapply</code> applies <code>FUN</code> to the first elements of each ... argument, the second elements, the third elements, and so on. Arguments are recycled if necessary. </p> <h3>Usage</h3> <pre> mapply(FUN, ..., MoreArgs = NULL, SIMPLIFY = TRUE, USE.NAMES = TRUE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>FUN</code></td> <td> <p>function to apply, found via <code><a href="match.fun.html">match.fun</a></code>.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>arguments to vectorize over (vectors or lists of strictly positive length, or all of zero length). See also ‘Details’.</p> </td></tr> <tr valign="top"><td><code>MoreArgs</code></td> <td> <p>a list of other arguments to <code>FUN</code>.</p> </td></tr> <tr valign="top"><td><code>SIMPLIFY</code></td> <td> <p>logical or character string; attempt to reduce the result to a vector, matrix or higher dimensional array; see the <code>simplify</code> argument of <code><a href="lapply.html">sapply</a></code>.</p> </td></tr> <tr valign="top"><td><code>USE.NAMES</code></td> <td> <p>logical; use names if the first ... argument has names, or if it is a character vector, use that character vector as the names.</p> </td></tr> </table> <h3>Details</h3> <p><code>mapply</code> calls <code>FUN</code> for the values of <code>...</code> (re-cycled to the length of the longest, unless any have length zero), followed by the arguments given in <code>MoreArgs</code>. The arguments in the call will be named if <code>...</code> or <code>MoreArgs</code> are named. </p> <p>Arguments with classes in <code>...</code> will be accepted, and their subsetting and <code>length</code> methods will be used. </p> <h3>Value</h3> <p>A list, or for <code>SIMPLIFY = TRUE</code>, a vector, array or list. </p> <h3>See Also</h3> <p><code><a href="lapply.html">sapply</a></code>, after which <code>mapply()</code> is modelled. </p> <p><code><a href="outer.html">outer</a></code>, which applies a vectorized function to all combinations of two arguments. </p> <h3>Examples</h3> <pre> mapply(rep, 1:4, 4:1) mapply(rep, times = 1:4, x = 4:1) mapply(rep, times = 1:4, MoreArgs = list(x = 42)) mapply(function(x, y) seq_len(x) + y, c(a = 1, b = 2, c = 3), # names from first c(A = 10, B = 0, C = -10)) word <- function(C, k) paste(rep.int(C, k), collapse = "") utils::str(mapply(word, LETTERS[1:6], 6:1, SIMPLIFY = FALSE)) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>