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

R语言 sensitivity包 template.replace()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-30 00:55:21 | 显示全部楼层 |阅读模式
template.replace(sensitivity)
template.replace()所属R语言包:sensitivity

                                        Replace Values in a Template Text
                                         在模板文本替换值

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

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

template.replace replaces keys within special markups with values in a so-called template file. Pieces of R code can be put into the markups of the template file, and are evaluated during the replacement.
template.replace所谓的模板文件中的值替换键在特殊标记。件R代码可以投入的模板文件的标记,并进行评估过程中更换。


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


template.replace(text, replacement, eval = FALSE,
                 key.pattern = NULL, code.pattern = NULL)



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

参数:text
vector of character strings, the template text.
矢量字符的字符串,模板文本。


参数:replacement
the list values to replace in text.
的列表值更换text。


参数:eval
boolean, TRUE if the code within code.pattern has to be evaluated, FALSE otherwise.
布尔,TRUE如果code.pattern内的代码进行评估,FALSE否则。


参数:key.pattern
custom pattern for key replacement (see below)
自定义模式键更换(见下文)


参数:code.pattern
custom pattern for code replacement (see below)
自定义模式的代码替换(见下文)


Details

详细信息----------Details----------

In most cases, a computational code reads its inputs from a text file. A template file is like an input file, but where some missing values, identified with generic keys, will be replaced by specific values.
在大多数情况下,计算代码从文本文件中读取它的输入。模板文件就像是一个输入文件,但在一些缺失值,确定与一般的按键,取而代之的将是具体的值。

By default, the keys are enclosed into markups of the form $(KEY).
默认情况下,键都包含标记的形式$(KEY)。

Code to be interpreted with R can be put in the template text. Pieces of code must be enclosed into markups of the form @{CODE}. This is useful for example for formating the key values (see example). For interpreting the code, set eval = TRUE.
代码来进行解释,其中R可以在模板文本。必须包含的代码块标记的形式@{CODE}。例如格式化的关键值(见例子),这是非常有用的。为了解释其中的代码,设置eval = TRUE。

Users can define custom patterns. These patterns must be perl-compatible regular expressions (see regexpr. The default ones are:
用户可以定义自定义模式。这些模式必须是Perl兼容的正则表达式(见regexpr。默认的是:


实例----------Examples----------


txt <- c("Hello $(name)!", "$(a) + $(b) = @{$(a)+$(b)}",
         "pi = @{format(pi,digits=5)}")
replacement <- list(name = "world", a = 1, b = 2)
# 1. without code evaluation:[1。没有代码的评价:]
txt.rpl1 <- template.replace(txt, replacement)
print(txt.rpl1)
# 2. with code evalutation:[2。代码评价; Sunjiazhuang。地球:]
txt.rpl2 <- template.replace(txt, replacement, eval = TRUE)
print(txt.rpl2)

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-5-19 07:23 , Processed in 0.020671 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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