modifyList(utils)
modifyList()所属R语言包:utils
Recursively Modify Elements of a List
递归修改列表中的元素
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Modifies a possibly nested list recursively by changing a subset of elements at each level to match a second list.
通过改变元素的一个子集,在每个级别相匹配的第二个列表递归修改可能嵌套列表。
用法----------Usage----------
modifyList(x, val)
参数----------Arguments----------
参数:x
a named list, possibly empty.
一个名为list,可能是空的。
参数:val
a named list with components to replace corresponding components in x.
一个组件的命名的名单,以取代在x相应的组件。
值----------Value----------
A modified version of x, with the modifications determined as follows (here, list elements are identified by their names). Elements in val which are missing from x are added to x. For elements that are common to both but are not both lists themselves, the component in x is replaced by the one in val. For common elements that are both lists, x[[name]] is replaced by modifyList(x[[name]], val[[name]]).
修改后的版本x,确定如下(在这里,他们的名字确定列表元素)的修改。在元素val这是缺少x添加到x。是共同的,但不能同时列出了自己的元素,在x组件取代由val之一。对于两份名单的共同要素,x[[name]]modifyList(x[[name]], val[[name]])取代。
作者(S)----------Author(s)----------
Deepayan Sarkar <a href="mailtoeepayan.Sarkar@R-project.org">Deepayan.Sarkar@R-project.org</a>
举例----------Examples----------
foo <- list(a = 1, b = list(c = "a", d = FALSE))
bar <- modifyList(foo, list(e = 2, b = list(d = TRUE)))
str(foo)
str(bar)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|