EVOLUTION-MANAGER
Edit File: modifyList.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: Recursively Modify Elements of 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 modifyList {utils}"><tr><td>modifyList {utils}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Recursively Modify Elements of a List</h2> <h3>Description</h3> <p>Modifies a possibly nested list recursively by changing a subset of elements at each level to match a second list. </p> <h3>Usage</h3> <pre> modifyList(x, val, keep.null = FALSE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>A named <code><a href="../../base/html/list.html">list</a></code>, possibly empty.</p> </td></tr> <tr valign="top"><td><code>val</code></td> <td> <p>A named list with components to replace corresponding components in <code>x</code>.</p> </td></tr> <tr valign="top"><td><code>keep.null</code></td> <td> <p> If <code>TRUE</code>, <code>NULL</code> elements in <code>val</code> become <code>NULL</code> elements in <code>x</code>. Otherwise, the corresponding element, if present, is deleted from <code>x</code>. </p> </td></tr> </table> <h3>Value</h3> <p>A modified version of <code>x</code>, with the modifications determined as follows (here, list elements are identified by their names). Elements in <code>val</code> which are missing from <code>x</code> are added to <code>x</code>. For elements that are common to both but are not both lists themselves, the component in <code>x</code> is replaced (or possibly deleted, depending on the value of <code>keep.null</code>) by the one in <code>val</code>. For common elements that are in both lists, <code>x[[name]]</code> is replaced by <code>modifyList(x[[name]], val[[name]])</code>. </p> <h3>Author(s)</h3> <p> Deepayan Sarkar <a href="mailto:Deepayan.Sarkar@R-project.org">Deepayan.Sarkar@R-project.org</a></p> <h3>Examples</h3> <pre> foo <- list(a = 1, b = list(c = "a", d = FALSE)) bar <- modifyList(foo, list(e = 2, b = list(d = TRUE))) str(foo) str(bar) </pre> <hr /><div style="text-align: center;">[Package <em>utils</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>