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

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

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

                                        Using and Creating On-line Documentation for Classes and
                                         使用类创建在线文档

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

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

Special documentation can be supplied to describe the classes and methods that are created by the software in the methods package.  Techniques to access this documentation and to create it
可提供特殊的文档来描述类和创建的方法是通过软件的方法包。技术来访问这个文件,并创建


获取类和方法的文档----------Getting documentation on classes and methods----------

You can ask for on-line help for class definitions, for specific methods for a generic function, and for general discussion of methods for a generic function.  These requests use the ? operator (see help for a general description of the operator).  Of course, you are at the mercy of the implementer as to whether there is any documentation on the corresponding topics.
你可以要求上线为类定义的帮助下,一个泛型函数的具体方法,一个泛型函数的方法进行一般性讨论。这些请求使用?运营商(见help一般的操作说明)。当然,你的实施者,以慈悲,是否有相应的主题文件。

Documentation on a class uses the argument class on the left of the ?, and the name of the class on the right; for example,
一类的文件使用参数class左?,和右边的类的名称;例如,

class ? genericFunction
class ? genericFunction

to ask for documentation on the class "genericFunction".
问文档类"genericFunction"。

When you want documentation for the methods defined for a particular function, you can ask either for a general discussion of the methods or for documentation of a particular method (that is, the method that would be selected for a particular set of actual arguments).
当你想为一个特定的功能定义的方法的文档,你可以要求一般性讨论的方法或特定方法的文档(即,将选择一组特定的实际参数的方法)。

Overall methods documentation is requested by calling the ? operator with methods as the left-side argument and the name of the function as the right-side argument. For example,
文件的总体方法是通过调用?运营商要求methods左侧的论点和作为右侧的参数的函数的名称。例如,

methods ? initialize
methods ? initialize

asks for documentation on the methods for the initialize function.
对文件要求上initialize函数的方法。

Asking for documentation on a particular method is done by giving a function call expression as the right-hand argument to the "?" operator.  There are two forms, depending on whether you prefer to give the class names for the arguments or expressions that you intend to use in the actual call.
作为右手参数的函数调用表达式"?"运营商在一个特定的方法文件的要求。有两种形式,取决于你是否愿意给,你打算用在实际调用的参数或表达式的类名。

If you planned to evaluate a function call, say myFun(x, sqrt(wt)) and wanted to find out something about the method that would be used for this call, put the call on the right of the "?" operator:
如果您计划来评估一个函数调用,说myFun(x, sqrt(wt))想找出此调用将使用的方法有关的东西,把的"?"经营者的权利的呼叫:

?myFun(x, sqrt(wt))
?myFun(x, sqrt(wt))

A method will be selected, as it would be for the call itself, and documentation for that method will be requested.  If myFun is not a generic function, ordinary documentation for the function will be requested.
将选择一种方法,因为这将是呼叫本身,将要求该方法的文档。 myFun如果是不是一个泛型函数,函数的普通文档将要求。

If you know the actual classes for which you would like method documentation, you can supply these explicitly in place of the argument expressions.  In the example above, if you want method documentation for the first argument having class "maybeNumber" and the second "logical", call the "?" operator, this time with a left-side argument method, and with a function call on the right using the class names as arguments:
如果你知道实际的类,而你想方法的文档,你可以提供这些明确的说法表达的地方。在上面的例子,如果你想第一个参数有类"maybeNumber"第二"logical",请与左侧的论点"?"运营商,这次<X方法的文档>,与上使用正确的类名作为参数的函数调用:

method ? myFun("maybeNumber", "logical")
method ? myFun("maybeNumber", "logical")

Once again, a method will be selected, this time corresponding to the specified classes, and method documentation will be requested.  This version only works with generic functions.
再次,方法将被选中,此时对应到指定的类,方法的文档将被要求。此版本只适用于通用功能。

The two forms each have advantages.  The version with actual arguments doesn't require you to figure out (or guess at) the classes of the arguments. On the other hand, evaluating the arguments may take some time, depending on the example. The version with class names does require you to pick classes, but it's otherwise unambiguous.  It has a subtler advantage, in that the classes supplied may be virtual classes, in which case no actual argument will have specifically this class.  The class "maybeNumber", for example, might be a class union (see the example for setClassUnion).
这两种形式各有优势。不要求你找出(或猜测)类的参数与实际参数的版本。另一方面,评估的参数可能需要一些时间,取决于这个例子。类名的版本确实需要你挑班,但它另有明确。它有一个微妙的优势,提供的类可能是虚拟类,没有实际的参数,在这种情况下,将有专门这个类。类"maybeNumber",例如,可能是一类工会(见setClassUnion的例子)。

In either form, methods will be selected as they would be in actual computation, including use of inheritance and group generic functions.  See selectMethod for the details, since it is the function used to find the appropriate method.
无论是哪种形式,方法将被选中,因为他们将在实际计算中,包括继承和泛型函数组的使用。看到selectMethod细节,因为它的功能是用来寻找适当的方法。


写作方法的文档----------Writing Documentation for Methods----------

The on-line documentation for methods and classes uses some extensions to the R documentation format to implement the requests for class and method documentation described above.  See the document Writing R Extensions for the available markup commands (you should have consulted this document already if you are at the stage of documenting your software).
在线文档的方法和类使用一些扩展到R格式的文件,实现以上所述的类和方法的文档的请求。请参阅文档写作R附加可用的标记命令(你应该谘询本文件,如果你已经是记录软件的阶段)。

In addition to the specific markup commands to be described, you can create an initial, overall file with a skeleton of documentation for the methods defined for a particular generic function:
除了要描述的特定标记命令,可以创建一个初步的,整体的文件骨架的文件定义一个特定的通用功能的方法:

promptMethods("myFun")
promptMethods("myFun")

will create a file, "myFun-methods.Rd" with a skeleton of documentation for the methods defined for function myFun. The output from promptMethods is suitable if you want to describe all or most of the methods for the function in one file, separate from the documentation of the generic function itself. Once the file has been filled in and moved to the "man" subdirectory of your source package, requests for methods documentation will use that file, both for specific methods documentation as described above, and for overall documentation requested by
将创建一个文件,myFun-methods.Rd的文件的方法为函数myFun定义骨架。从promptMethods输出是合适的,如果你想描述的全部或大部分在一个文件中的功能的方法,泛型函数本身的文件分开。一旦该文件已被填充和移动man你的源码包的子目录,方法的文档将使用这两个文件的具体方法如上所述,该文件的请求,并要求整体文件

methods ? myFun
methods ? myFun

You are not required to use promptMethods, and if you do, you may not want to use the entire file created:
你是不是需要使用promptMethods,如果这样做,你可能不希望使用整个创建的文件:

If you want to document the methods in the file containing the documentation for the generic function itself, you can
如果你想记录的方法中包含泛型函数本身的文档的文件,你可以

On the other hand, if these are auxiliary methods, and you only want to document the added or modified software, you should strip
另一方面,如果这些辅助方法,你只是想记录的添加或修改的软件,你应该剥夺

If you simply want to direct documentation for one or more methods to a particular R documentation file, insert the appropriate alias.
如果你只是想一个或多个方法到特别是R文档文件的文件直接插入相应的别名。

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-23 12:01 , Processed in 0.019252 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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