list2env(base)
list2env()所属R语言包:base
From A List, Build or Add To an Environment
从列表中,建立或加入的环境
译者:生物统计家园网 机器人LoveR
描述----------Description----------
From a named list x, create an environment containing all list components as objects, or “multi-assign” from x into a pre-existing environment.
从一个名为list x,environment到一个预先存在的环境中创建一个x包含所有对象的列表组件,或“多分配”。
用法----------Usage----------
list2env(x, envir = NULL, parent = parent.frame(),
hash = (length(x) > 100), size = max(29L, length(x)))
参数----------Arguments----------
参数:x
a list, where names(x) must not contain empty ("") elements.
list,其中names(x)不能包含空("")元素。
参数:envir
an environment or NULL.
environment或NULL。
参数:parent
(for the case envir = NULL): a parent frame aka enclosing environment, see new.env.
(为envir = NULL):父框架又名封闭的环境,看到new.env。
参数:hash
(for the case envir = NULL): logical indicating if the created environment should use hashing, see new.env.
(为envir = NULL):逻辑表示,如果创建的环境中应该使用散列,看到new.env。
参数:size
(in the case envir = NULL, hash = TRUE): hash size, see new.env.
(在envir = NULL, hash = TRUE):散列大小,看到new.env。
Details
详情----------Details----------
This will be very slow for large inputs unless hashing is used on the environment.
这将是非常缓慢的大投入哈希,除非是对环境的使用。
Environments must have uniquely named entries, but named lists need not: where the list has duplicate names it is the last element with the name that is used. Empty names throw an error.
环境必须有唯一命名的条目,但命名名单不需要列表有重复的名称,它是与所使用的名称的最后一个元素。空名抛出一个错误。
值----------Value----------
An environment, either newly created (as by new.env) if the envir argument was NULL, otherwise the updated environment envir. Since environments are never duplicated, the argument envir is also changed.
environment,无论是新创建(new.env)如果envir论点是NULL,否则更新的环境envir。因为环境永远不会重复,论据envir也发生了变化。
作者(S)----------Author(s)----------
Martin Maechler
参见----------See Also----------
environment, new.env, as.environment; further, assign.
environment,new.env,as.environment;进一步,assign。
The (semantical) “inverse”: as.list.environment.
(语义)“逆”:as.list.environment。
举例----------Examples----------
L <- list(a=1, b=2:4, p = pi, ff = gl(3,4,labels=LETTERS[1:3]))
e <- list2env(L)
ls(e)
stopifnot(ls(e) == sort(names(L)),
identical(L$b, e$b)) # "$" working for environments as for lists[“$”列表的工作环境]
## consistency, when we do the inverse:[#一致性,当我们这样做的逆:]
ll <- as.list(e) # -> dispatching to the as.list.environment() method[ - >调度到的as.list.environment()方法]
rbind(names(L), names(ll)) # not in the same order, typically,[通常情况下,不以相同的顺序,]
# but the same content:[但相同的内容:]
stopifnot(identical(L [sort.list(names(L ))],
ll[sort.list(names(ll))]))
## now add to e -- can be seen as a fast "multi-assign":[#现在添加到e - 一种快速的“多分配”中可以看出:]
list2env(list(abc = LETTERS, note = "just an example",
df = data.frame(x=rnorm(20), y = rbinom(20,1, pr=0.2))),
envir = e)
utils::ls.str(e)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|