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

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

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

                                        A Completion Generator for R
                                         一个完成的R发生器

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

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

This package provides a mechanism to generate relevant completions from a partially completed command line.  It is not intended to be useful by itself, but rather in conjunction with other mechanisms that use it as a backend.  The functions listed in the usage section provide a simple control and query mechanism.  The actual interface consists of a few unexported functions described further down.
这个包提供了一种机制,以从部分完成的命令行生成有关的落成。它并不打算成为有用本身,而是在与其他机制作为后端使用。在使用“部分中列出的功能提供了一个简单的控制和查询机制。实际的接口包括几个导出,功能描述进一步下降。


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



rc.settings(ops, ns, args, func, ipck, S3, data, help,
            argdb, files)

rc.status()
rc.getOption(name)
rc.options(...)

.DollarNames(x, pattern)

## Default S3 method:[默认方法]
.DollarNames(x, pattern = "")
## S3 method for class 'list'
.DollarNames(x, pattern = "")
## S3 method for class 'environment'
.DollarNames(x, pattern = "")




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

参数:ops, ns, args, func, ipck, S3, data, help, argdb, files
logical, turning some optional completion features on and off.     
逻辑,把完成一些可选功能和关闭。

ops:activates completion after the $ and @ operators  
ops:激活完成$和@运营商后

ns:controls namespace related completions  
ns:控制命名空间相关落成

args:enables completion of function arguments  
args:使完成函数的参数

func:enables detection of functions.  If enabled, a customizable extension ("(" by default) is appended to function names.  The process of determining whether a potential completion is a function requires evaluation, including for lazy loaded symbols.  This is extremely undesirable for large objects, because of potentially wasteful use of memory in addition to the time overhead associated with loading.  For this reason, this feature is disabled by default.   
func:使检测功能。如果启用,可定制的扩展("("默认情况下)被追加到函数名。确定是否有潜在的完成是一个函数的过程中,需要评估,包括延迟加载符号。这是非常不可取的大型物体,因为除了时间与负载相关的开销可能浪费的内存使用。出于这个原因,这个功能默认是禁用的。

S3: when args=TRUE, activates completion on arguments of all S3 methods (otherwise just the generic, which usually has very few arguments)   
S3当args=TRUE,激活完成所有S3方法的参数(否则只是一般的,通常有极少数的论据)

ipck: enables completion of installed package names inside library and require   
ipck:可以完成安装的软件包名内library和require

data: enables completion of data sets (including those already visible) inside data   
data:使内data完成数据集(包括那些已经可见)

help: enables completion of help requests starting with a question mark, by looking inside help index files   
help:一个问号开始的帮助请求后,可以通过里面寻找帮助索引文件

argdb: when args=TRUE, completion is attempted on function arguments.  Generally, the list of valid arguments is determined by dynamic calls to args. While this gives results that are technically correct, the use of the ... argument often hides some useful arguments. To give more flexibility in this regard, an optional table of valid arguments names for specific functions is retained internally.  Setting argdb=TRUE enables preferential lookup in this internal data base for functions with an entry in it.  Of course, this is useful only when the data base contains information about the function of interest.  Some functions are included in the package (the maintainer is happy to add more upon request), and more can be added by the user through the unexported function .addFunctionInfo (see below).   
argdb:args=TRUE,完成对函数参数的尝试。一般来说,有效的参数列表是动态调用args。虽然这给在技术上是正确的结果,使用...参数往往隐藏了一些有用的参数。在这方面给予更多的灵活性,一个有效的参数为特定功能的名称可选表内部被保留。设置argdb=TRUE可以在这个内部数据的基础上优惠查找功能中的一个条目。当然,这是非常有用的,只有当数据的基础上包含利益的功能信息。有些功能都包含在包(维护者是要求增加更多的快乐),更可以通过导出,功能由用户添加.addFunctionInfo(见下文)。

files: enables filename completion in R code.  This is initially set to FALSE, in which case the underlying completion front-end can take over (and hopefully do a better job than we would have done).  For systems where no such facilities exist, this can be set to TRUE if file name completion is desired.  This is used on Windows (where file paths including spaces do work): on Unix-alikes readline's filename completion is normally used.      All settings are turned on by default except ipck, func and files.  Turn more off if your CPU cycles are valuable; you will still retain basic completion on names of objects in the search list.  See below for additional details.  
files:可以在R代码的文件名完成。这是初步建立FALSE,在这种情况下,基本完成前端可以接管(希望做的比我们会做一个更好的工作)。没有这样的设施存在的系统,可以设置为TRUE如果所需的文件名完成。这是在Windows(包括空格的文件路径做的工作):在Unix相似者readlines文件名完成通常使用。所有设置都默认打开除了ipck,func和files。开启,关闭,如果您的CPU周期是有价值的,你仍然会保留在基本完成,在搜索列表中的对象的名称。更多细节见下文。


参数:name, ...
user-settable options.  Currently valid names are     
用户可设置的选项。目前有效的名字是

function.suffix: default "("   
function.suffix:默认"("

funarg.suffix: default " = "   
funarg.suffix:默认" = "

package.suffix default "::"      See options for detailed usage description.  
package.suffix默认"::"见options详细的使用说明。


参数:x
An R object for which valid names after "$" are computed and returned.  
为有效名称后"$"计算并返回一个R对象。


参数:pattern
A regular expression.  Only matching names are returned.  
正则表达式。只有匹配的名称返回。


Details

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

There are several types of completion, some of which can be disabled using rc.settings.  The most basic level, which can not be turned off once the package is loaded, provides completion on names visible on the search path, along with a few special keywords (e.g. TRUE).  This type of completion is not attempted if the partial "word" (a.k.a. token) being completed is empty (since there would be too many completions).  The more advanced types of completion are described below.
完成有几种类型,其中一些可以使用rc.settings禁用。不能关闭,一旦加载包,提供最基本的层面上,完成名称上的搜索路径中可见,随着一些特殊的关键字,(如TRUE)。这种类型的完成是没有尝试,如果是空的部分字“(又称令牌),完成(因为会有太多的落成)。完成更高级的类型介绍如下。

When the ops setting is turned on, completion after $ and @ is attempted.  This requires the prefix to be evaluated, which is attempted unless it involves an explicit function call (implicit function calls involving the use of [, $, etc do not inhibit evaluation).
ops设置时打开,完成后$和@尝试。这就需要进行评估,这是尝试,除非它涉及到一个明确的函数调用(隐函数调用涉及[使用前缀,$等不抑制评价)。

Valid completions after the $ extractor are determined by the generic function .DollarNames.  Some basic methods are provided, and more can be written for custom classes.
确定由通用功能$.DollarNames提取后的有效落成。提供一些基本的方法,更可自定义类的书面。

When the ns setting is turned on, completion inside namespaces is attempted when a token is preceded by the :: or ::: operators.  Additionally, the basic completion mechanism is extended to include attached namespaces, or more precisely, foopkg:: becomes a valid completion of foo if the return value of search() includes the string "package:foopkg".
ns设置打开时,尝试命名空间内完成,当一个令牌::或:::运营商的前面。此外,基本完成机制扩展至包括附加的命名空间,或更确切地说,foopkg::成为有效的完成了foo如果search()返回值包含了字符串"package:foopkg" 。

The completion of package namespaces applies only to attached packages, i.e. if MASS is not attached (whether or not it is loaded), MAS will not complete to MASS::. However, attempted completion inside an apparent namespace will attempt to load the namespace if it is not already loaded, e.g. trying to complete on MASS::fr will load MASS (but not necessarily attach it) even if it is not already loaded.
完成包的命名空间只适用于附加的软件包,也就是说,如果MASS不附(不论它是否被加载),MAS将无法完成MASS::。然而,试图完成一个明显的命名空间内将尝试加载的命名空间,如果它尚未被加载,如试图完成MASS::fr将载入MASS(但不一定附加),即使它是不是已经加载。

When the args setting is turned on, completion on function arguments is attempted whenever deemed appropriate.  The mechanism used will currently fail if the relevant function (at the point where completion is requested) was entered on a previous prompt (which implies in particular that the current line is being typed in response to a continuation prompt, usually +).  Note that separation by newlines is fine.
args设置打开时,认为适当时,试图完成函数参数。目前使用的机制将失败,如果相关的功能(在完成要求的地方点)输入先前的提示(这意味着在特定的输入线,目前正在延续提示符,通常是+ )。请注意,由换行符分离罚款。

The list of possible argument completions that is generated can be misleading.  There is no problem for non-generic functions (except that ... is listed as a completion; this is intentional as it signals the fact that the function can accept further arguments).  However, for generic functions, it is practically impossible to give a reliable argument list without evaluating arguments (and not even then, in some cases), which is risky (in addition to being difficult to code, which is the real reason it hasn't even been tried), especially when that argument is itself an inline function call.  Our compromise is to consider arguments of all currently available methods of that generic.  This has two drawbacks.  First, not all listed completions may be appropriate in the call currently being constructed.  Second, for generics with many methods (like print and plot), many matches will need to be considered, which may take a noticeable amount of time.  Despite these drawbacks, we believe this behaviour to be more useful than the only other practical alternative, which is to list arguments of the generic only.
可能产生的参数落成名单可能会产生误导。有没有非泛型函数的问题(除...被列为完成,这是故意的,因为它标志着该函数可以接受进一步的论据)。然而,通用的功能,它几乎是不可能没有评估参数(而不是即使这样,在某些情况下),这是很危险的(除了难以代码,这是真正的原因,还没给了可靠的参数列表甚至曾经尝试过),尤其是当这样的说法本身就是一个inline函数调用。我们的妥协是考虑目前所有可用的泛型方法的参数。这有两个缺点。首先,并非所有上市的落成,可能是适当的,在目前正在兴建的呼叫。其次,有很多方法的泛型(如print和plot),很多比赛需要考虑,这可能需要的时间明显。尽管有这些缺点,我们认为这种行为是多只其他实用的替代品,这是通用唯一列出的参数有用。

Only S3 methods are currently supported in this fashion, and that can be turned off using the S3 setting.
S3的唯一方法是目前支持这种方式,可以使用S3设置关闭。

Since arguments can be unnamed in R function calls, other types of completion are also appropriate whenever argument completion is.  Since there are usually many many more visible objects than formal arguments of any particular function, possible argument completions are often buried in a bunch of other possibilities. However, recall that basic completion is suppressed for blank tokens.  This can be useful to list possible arguments of a function.  For example, trying to complete seq([TAB] and seq(from = 1, [TAB]) will both list only the arguments of seq (or any of its methods), whereas trying to complete seq(length[TAB] will list both the length.out argument and the length( function as possible completions. Note that no attempt is made to remove arguments already supplied, as that would incur a further speed penalty.
由于参数可以是无名R函数调用,也适当的时候完成其他类型参数完成。既然有通常很多更为明显比任何特定功能的正式参数的对象,参数可能的落成经常埋在一堆其他的可能性。不过,记得,基本完成空白令牌抑制。列出可能的参数的函数,这可能是有用的。例如,试图完成seq([TAB]和seq(from = 1, [TAB])两个列表的参数seq(或它的任何方法),而试图完成seq(length[TAB]会同时列出length.out参数和length(功能尽可能落成的。请注意,没有试图删除已提供的,因为这会招致进一步的速度刑罚的论据。

For a few special functions (library, data, etc), the first argument is treated specially, in the sense that normal completion is suppressed, and some function specific completions are enabled if so requested by the settings.  The ipck setting, which controls whether library and require will complete on installed packages, is disabled by default because the first call to installed.packages is potentially time consuming (e.g. when packages are installed on a remote network file server).  Note, however, that the results of a call to installed.packages is cached, so subsequent calls are usually fast, so turning this option on is not particularly onerous even in such situations.
对于一些特殊功能(library,data等),第一个参数是特殊对待,在正常完成的压抑感,并设置一些功能的具体落成启用若有要求。 ipck设置,它控制是否library和require将完成安装的软件包,默认情况下禁用,因为第一次调用installed.packages可能是费时(如包时,远程网络文件服务器上安装)。但是请注意,说调用installed.packages一个的结果缓存,那么随后调用通常是速度快,所以把这个选项是,即使在这种情况下不特别繁重。


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

rc.status returns, as a list, the contents of an internal (unexported) environment that is used to record the results of the last completion attempt.  This can be useful for debugging.  For such use, one must resist the temptation to use completion when typing the call to rc.status itself, as that then becomes the last attempt by the time the call is executed.
rc.status回报,作为一个列表,内部环境,是用来记录的最后完成的尝试的结果(导出,)的内容。这可能是有用的用于调试。对于这样的使用,必须抵制诱惑,使用完成打字时调用rc.status本身,因为这便成为呼叫执行时的最后一次尝试。

The items of primary interest in the returned list are:
在返回列表中的主要兴趣的项目是:


参数:comps
the possible completions generated by the last call to .completeToken, as a character vector  
.completeToken最后一次通话所产生的可能的完成,作为特征向量


参数:token
the token that was (or, is to be) completed, as set by the last call to .assignToken (possibly inside a call to .guessTokenFromLine)  
令牌(或)完成,最后一次通话设置.assignToken(可能内调用.guessTokenFromLine)


参数:linebuffer
the full line, as set by the last call to .assignLinebuffer
在全行的最后一次通话.assignLinebuffer设置


参数:start
the start position of the token in the line buffer, as set by the last call to .assignStart  
行缓冲区的标记的开始位置,最后一次通话设置.assignStart


参数:end
the end position of the token in the line buffer, as set by the last call to .assignEnd  
结束位置的行缓冲区中的令牌,最后一次通话设置.assignEnd


参数:fileName
logical, indicating whether the cursor is currently inside quotes.  If so, no completion is attempted.  A reasonable default behaviour for the backend in that case is to fall back to filename completion.   
逻辑,指示光标是否是目前引号内。如果是这样,没有完成的尝试。后端在这种情况下,一个合理的默认行为是回落到文件名完成。


参数:fguess
the name of the function rcompgen thinks the cursor is currently inside  
功能rcompgen的名字认为光标是目前内


参数:isFirstArg
logical.  If cursor is inside a function, is it the first argument?  
逻辑。如果光标在函数内部,是它的第一个参数呢?

In addition, the components settings and options give the current values of settings and options respectively.
此外,组件settings和options分别设置和选项的当前值。

rc.getOption and rc.options behave much like getOption and options respectively.
rc.getOption和rc.options的行为很像getOption和options分别。


导出,空气污染指数----------Unexported API----------

There are several unexported functions in the package.  Of these,  a few are special because they provide the API through which other mechanisms can make use of the facilities provided by this package (they are unexported because they are not meant to be called directly by users).  The usage of these functions are:
有几个导出,功能包中。这些,有几个是特殊的,因为他们提供的API,通过其他机制可以利用这个包所提供的设施(他们被导出,因为它们不意味着要由用户直接调用)。这些功能的用法是:


注意----------Note----------

If you are uncomfortable with unsolicited evaluation of pieces of code, you should set ops = FALSE.  Otherwise, trying to complete foo@ba will evaluate foo, trying to complete foo[i,1:10]$ba will evaluate foo[i,1:10], etc.  This should not be too bad, as explicit function calls (involving parentheses) are not evaluated in this manner.  However, this will affect lazy loaded symbols (and presumably other promise type thingies).
如果你不舒服的代码块的不请自来的评价,你应该设置ops = FALSE。否则,试图完成foo@ba将评估foo,试图完成foo[i,1:10]$ba将评估foo[i,1:10],等等,这不应该是太糟糕了,因为明确的函数调用(包括括号)不以这种方式进行评估。然而,这会影响懒加载的符号(和承诺想必其他类型的搜索术语)。


作者(S)----------Author(s)----------


Deepayan Sarkar, <a href="mailto:deepayan.sarkar@r-project.org">deepayan.sarkar@r-project.org</a>

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-23 11:52 , Processed in 0.022563 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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