找回密码
 注册
查看: 1888|回复: 0

R语言:delayedAssign()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-16 18:57:26 | 显示全部楼层 |阅读模式
delayedAssign(base)
delayedAssign()所属R语言包:base

                                        Delay Evaluation
                                         延缓评价

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

delayedAssign creates a promise to evaluate the given expression if its value is requested.  This provides direct access to the lazy evaluation mechanism used by R for the evaluation of (interpreted) functions.
delayedAssign创建一个承诺来评估给定的表达式,如果其值要求。这提供了直接访问的懒惰的评价机制,用于由R(解释)功能的评价。


用法----------Usage----------


delayedAssign(x, value, eval.env = parent.frame(1),
              assign.env = parent.frame(1))



参数----------Arguments----------

参数:x
a variable name (given as a quoted string in the function call)
一个变量的名称(在引号的字符串函数调用)


参数:value
an expression to be assigned to x
被分配x的表达


参数:eval.env
an environment in which to evaluate value
环境评估value


参数:assign.env
an environment in which to assign x
一个环境,在其中指定x


Details

详情----------Details----------

Both eval.env and assign.env default to the currently active environment.
既eval.env和assign.env默认为当前活跃的环境。

The expression assigned to a promise by delayedAssign will not be evaluated until it is eventually "forced".  This happens when the variable is first accessed.
分配到delayedAssign的承诺的表达将不进行评估,直到它最终被逼。这种情况发生时该变量第一次被访问。

When the promise is eventually forced, it is evaluated within the environment specified by eval.env (whose contents may have changed in the meantime).  After that, the value is fixed and the expression will not be evaluated again.
承诺最终被迫当,这是在eval.env(同时可能改变其内容)指定的环境评估。在此之后,该值是固定的,表达不会再次进行评估。


值----------Value----------

This function is invoked for its side effect, which is assigning a promise to evaluate value to the variable x.
其副作用,这是分配的承诺,以评估value变x这个函数被调用。


参见----------See Also----------

substitute, to see the expression associated with a promise.
substitute,看到与承诺相关的表达。


举例----------Examples----------


msg <- "old"
delayedAssign("x", msg)
msg <- "new!"
x #- new![ - 新!]
substitute(x) #- x (was 'msg' ?)[ -  X(“味精”吗?)]

delayedAssign("x", {
    for(i in 1:3)
        cat("yippee!\n")
    10
})

x^2 #- yippee[ -  yippee的]
x^2 #- simple number[ - 简单的数字]

e <- (function(x, y = 1, z) environment())(1+2, "y", {cat(" HO! "); pi+2})
(le &lt;- as.list(e)) # evaluates the promises[评估的承诺]


转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-5-4 23:32 , Processed in 0.021163 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表