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

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

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

                                        S3 Group Generic Functions
                                         S3组通用功能

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

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

Group generic methods can be defined for four pre-specified groups of functions, Math, Ops, Summary and Complex. (There are no objects of these names in base R, but there are in the methods package.)
集团通用的方法,可以定义为四个预先指定的功能,Math,Ops,Summary和Complex。 (有没有对象的在基地ŕ这些名字,但有methods包。)

A method defined for an individual member of the group takes precedence over a method defined for the group as a whole.
组个别成员定义的方法,优先接管组作为一个整体定义的方法。


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


## S3 methods for group generics have prototypes:
Math(x, \dots)
Ops(e1, e2)
Complex(z)
Summary(\dots, na.rm = FALSE)



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

参数:x, z, e1, e2
objects.
对象。


参数:...
further arguments passed to methods.
进一步的参数传递方法。


参数:na.rm
logical: should missing values be removed?
逻辑:应被删除缺失值吗?


Details

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

There are four groups for which S3 methods can be written, namely the "Math", "Ops", "Summary" and "Complex" groups.  These are not R objects in base R, but methods can be supplied for them and base R contains factor, data.frame and difftime methods for the first three groups.  (There is also a ordered method for Ops, POSIXt and Date methods for Math and Ops, package_version methods for Ops and Summary, as well as a ts method for Ops in package stats.)
有四组S3的方法可以被写入,即"Math","Ops","Summary"和"Complex"组。这些都不是在基地ŕR对象,但方法可以为他们提供基地R包含factor,data.frame和difftime前三组的方法。 (也有一个orderedOps,POSIXt方法和DateMath和Ops,package_version方法方法Ops和Summary,以及一个ts方法Ops包stats)。

Group "Math":
集团"Math":

abs, sign, sqrt,<br> floor, ceiling, trunc,<br> round, signif
abs,sign,sqrt参考floor,ceiling,trunc参考round,signif

exp, log,  expm1, log1p,<br> cos, sin, tan,<br> acos, asin, atan
exp,log,expm1,log1p参考cos,sin,tan参考acos,asin,atan

cosh, sinh, tanh,<br> acosh, asinh, atanh
cosh,sinh,tanh参考acosh,asinh,atanh

lgamma, gamma, digamma, trigamma        
lgamma,gamma,digamma,trigamma

cumsum, cumprod, cummax, cummin
cumsum,cumprod,cummax,cummin

Members of this group dispatch on x.  Most members accept only one argument, but members log, round and signif accept one or two arguments, and trunc accepts one or more.
该组的成员派遣x。大多数成员只接受一个参数,但成员log,round和signif接受一个或两个参数,trunc接受的一个或多个。

Group "Ops":
集团"Ops":

"+", "-", "*", "/", "^", "%%", "%/%"
"+","-","*","/","^","%%","%/%"

"&amp;", "|", "!"
"&amp;","|","!"

"==", "!=", "<", "<=", ">=", ">"
"==","!=","<","<=",">=",">"

This group contains both binary and unary operators (+, - and !): when a unary operator is encountered the Ops method is called with one argument and e2 is missing.
该组包含的二元和一元操作符(+,-和!):一元运算符时遇到了Ops方法是用一个参数调用<X >缺少。

The classes of both arguments are considered in dispatching any member of this group.  For each argument its vector of classes is examined to see if there is a matching specific (preferred) or Ops method.  If a method is found for just one argument or the same method is found for both, it is used. If different methods are found, there is a warning about "incompatible methods": in that case or if no method is found for either argument the internal method is used.
两个参数的类被认为是该组的任何成员调度。为每一个参数,其向量类检查,看看是否有一个匹配的具体(首选)或Ops方法。如果一个方法只有一个参数或相同的方法发现,它是用来发现。如果发现了不同的方法,有一个警告:“不相容的方法”方法在这种情况下,如果没有发现任一参数的内部方法使用。

If the members of this group are called as functions, any argument names are removed to ensure that positional matching is always used.
如果这个小组的成员函数调用,任何参数的名字被删除,以确保始终使用位置匹配。

Group "Summary":
集团"Summary":

all, any
all,any

sum, prod
sum,prod

min, max
min,max

range
range

Members of this group dispatch on the first argument supplied.
这个小组的成员派出的第一个提供的参数。

Group "Complex":
集团"Complex":

Arg, Conj, Im, Mod, Re
Arg,Conj,Im,Mod,Re

Members of this group dispatch on z.
该组的成员派遣z。

Note that a method will be used for one of these groups or one of its members only if it corresponds to a "class" attribute, as the internal code dispatches on oldClass and not on class.  This is for efficiency: having to dispatch on, say, Ops.integer would be too slow.
注意方法将被用于为这些群体之一,其成员之一,只有当它相当于一个"class"属性作为oldClass不class的内部代码调度。这是为了提高效率:派遣,说,Ops.integer太慢。

The number of arguments supplied for primitive members of the "Math" group generic methods is not checked prior to dispatch.
"Math"组泛型方法的原始成员提供的参数数目不检查前派遣。

There is no lazy evaluation of arguments for group-generic functions.
有没有懒惰的评价参数组通用功能。


技术细节----------Technical Details----------

These functions are all primitive and internal generic.
这些功能都是原始和内部通用。

The details of method dispatch and variables such as .Generic are discussed in the help for UseMethod.  There are a few small differences:
方法调度的细节,如变量.Generic讨论在UseMethod帮助。也有一些小的差异:

For the operators of group Ops, the object .Method is a length-two character vector with elements the methods selected for the left and right arguments respectively.  (If no method was selected, the corresponding element is "".)
为运营商组Ops,对象.Method长度两个元素的特征向量分别为左,右的论点选定的方法。 (如果没有方法被选中,相应的元素是""。)

Object .Group records the group used for dispatch (if a specific method is used this is "").
对象.Group记录的调度使用(如果使用特定的方法,这是"")组。


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

Package methods does contain objects with these names, which it has re-used in confusing similar (but different) ways.  See the help for that package.
包methods确实包含这些名字,它一直处于混乱类似(但不同)的方式重新使用的对象。看到该软件包的帮助。


参考文献----------References----------

Chambers, J. M.  and Hastie, T. J. eds (1992) Statistical Models in S. Wadsworth &amp; Brooks/Cole.

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

methods for methods of non-internal generic functions.
methods非内部的通用功能的方法。

S4groupGeneric for group generics for S4 methods.
为S4方法泛型S4groupGeneric。


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


require(utils)

d.fr <- data.frame(x=1:9, y=stats::rnorm(9))
class(1 + d.fr) == "data.frame" ##-- add to d.f. ...[# - 添加到D.F.的...]

methods("Math")
methods("Ops")
methods("Summary")
methods("Complex")  # none in base R[没有在基地&#341;]

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-24 04:58 , Processed in 0.023941 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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