EVOLUTION-MANAGER
Edit File: list_modify.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: Modify a list</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 list_modify {purrr}"><tr><td>list_modify {purrr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Modify a list</h2> <h3>Description</h3> <p><code>list_modify()</code> and <code>list_merge()</code> recursively combine two lists, matching elements either by name or position. If a sub-element is present in both lists <code>list_modify()</code> takes the value from <code>y</code>, and <code>list_merge()</code> concatenates the values together. </p> <p><code>update_list()</code> handles formulas and quosures that can refer to values existing within the input list. Note that this function might be deprecated in the future in favour of a <code>dplyr::mutate()</code> method for lists. </p> <h3>Usage</h3> <pre> list_modify(.x, ...) list_merge(.x, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>.x</code></td> <td> <p>List to modify.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>New values of a list. Use <code>zap()</code> to remove values. </p> <p>These values should be either all named or all unnamed. When inputs are all named, they are matched to <code>.x</code> by name. When they are all unnamed, they are matched positionally. </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> </table> <h3>Examples</h3> <pre> x <- list(x = 1:10, y = 4, z = list(a = 1, b = 2)) str(x) # Update values str(list_modify(x, a = 1)) # Replace values str(list_modify(x, z = 5)) str(list_modify(x, z = list(a = 1:5))) # Remove values str(list_modify(x, z = zap())) # Combine values str(list_merge(x, x = 11, z = list(a = 2:5, c = 3))) # All these functions support tidy dots features. Use !!! to splice # a list of arguments: l <- list(new = 1, y = zap(), z = 5) str(list_modify(x, !!!l)) </pre> <hr /><div style="text-align: center;">[Package <em>purrr</em> version 0.3.4 <a href="00Index.html">Index</a>]</div> </body></html>