EVOLUTION-MANAGER
Edit File: expand_grid.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: Create a tibble from all combinations of inputs</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 expand_grid {tidyr}"><tr><td>expand_grid {tidyr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Create a tibble from all combinations of inputs</h2> <h3>Description</h3> <p>Create a tibble from all combinations of inputs </p> <h3>Usage</h3> <pre> expand_grid(..., .name_repair = "check_unique") </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>...</code></td> <td> <p>Name-value pairs. The name will become the column name in the output.</p> </td></tr> <tr valign="top"><td><code>.name_repair</code></td> <td> <p>Treatment of problematic column names: </p> <ul> <li> <p><code>"minimal"</code>: No name repair or checks, beyond basic existence, </p> </li> <li> <p><code>"unique"</code>: Make sure names are unique and not empty, </p> </li> <li> <p><code>"check_unique"</code>: (default value), no name repair, but check they are <code>unique</code>, </p> </li> <li> <p><code>"universal"</code>: Make the names <code>unique</code> and syntactic </p> </li> <li><p> a function: apply custom name repair (e.g., <code>.name_repair = make.names</code> for names in the style of base R). </p> </li> <li><p> A purrr-style anonymous function, see <code><a href="../../rlang/html/as_function.html">rlang::as_function()</a></code> </p> </li></ul> <p>This argument is passed on as <code>repair</code> to <code><a href="../../vctrs/html/vec_as_names.html">vctrs::vec_as_names()</a></code>. See there for more details on these terms and the strategies used to enforce them.</p> </td></tr> </table> <h3>Value</h3> <p>A tibble with one column for each input in <code>...</code>. The output will have one row for each combination of the inputs, i.e. the size be equal to the product of the sizes of the inputs. This implies that if any input has length 0, the output will have zero rows. </p> <h3>Compared to <a href="../../base/html/expand.grid.html">expand.grid</a></h3> <ul> <li><p> Varies the first element fastest. </p> </li> <li><p> Never converts strings to factors. </p> </li> <li><p> Does not add any additional attributes. </p> </li> <li><p> Returns a tibble, not a data frame. </p> </li> <li><p> Can expand any generalised vector, including data frames. </p> </li></ul> <h3>Examples</h3> <pre> expand_grid(x = 1:3, y = 1:2) expand_grid(l1 = letters, l2 = LETTERS) # Can also expand data frames expand_grid(df = data.frame(x = 1:2, y = c(2, 1)), z = 1:3) # And matrices expand_grid(x1 = matrix(1:4, nrow = 2), x2 = matrix(5:8, nrow = 2)) </pre> <hr /><div style="text-align: center;">[Package <em>tidyr</em> version 1.1.2 <a href="00Index.html">Index</a>]</div> </body></html>