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

R语言 externalVector包 setVirtualMethod()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-25 17:27:32 | 显示全部楼层 |阅读模式
setVirtualMethod(externalVector)
setVirtualMethod()所属R语言包:externalVector

                                         Set a virtual method for a given signature
                                         对于一个给定的签名设置虚拟方法

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

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

This sets a method for a signature. If there is no generic with the given name, it also creates the appropriate generic. If called, the method generates an error indicating the classes of the arguments which are part of the signature.
这设置一个签名的方法。如果没有给定名称的通用,它也建立相应的通用。如果调用,该方法生成一个错误,指出这是签名的一部分参数的类。


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


setVirtualMethod(name, signature.virtual, signature.nonvirtual = character(), ..., where = topenv(parent.frame()))



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

参数:name
The character-string name of the generic function.  
字符的字符串名称的通用功能。


参数:signature.virtual
Signature of the arguments for which the virtual method is being set. All of these arguments must have a virtual class in the signature.  
被设置为虚拟方法的参数的签名。所有这些参数都必须有一个签名的虚拟类。


参数:signature.nonvirtual
Signature for other arguments. Any ommitted argument is assumed to have class "ANY".  
其他参数的签名。任何省略的参数假设有一流的“ANY”。


参数:...
Other arguments. See details.  
其他参数。查看详情。


参数:where
The database in which to store the definition of the method.  
该数据库在其中存储的方法定义。


Details

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

If the generic for name is not defined, an attempt is made to create it with setGeneric(name, ..., where = where).
如果通用的name没有被定义,试图创建setGeneric(name, ..., where = where)。


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

This method exists for its side-effect of setting up the virtual method.
这种方法存在其设立的虚拟方法的副作用。

The return value is the result from the call to setMethod to create the virtual method.
返回值是从呼叫setMethod创建的虚拟方法的结果。


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

setGeneric, setMethod



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


setClass("myMatrix")
setVirtualMethod("dim", "myMatrix")
setVirtualMethod("dimnames", "myMatrix")
setClass("myMatrix2", representation(val="numeric",
                                     d = "integer",
                                     dn = "list"),
         contains="myMatrix")
x <- new("myMatrix2", val=1:4, d = as.integer(c(2, 2)),
         dn = list(LETTERS[1:2], letters[1:2]))
## A call dim(x) or dimnames(x) would generate an error here[#呼叫暗淡(x)或dimnames(X)将在这里产生一个错误]
setMethod("dim", "myMatrix", function(x) x@d)
setMethod("dimnames", "myMatrix", function(x) x@dn)
dim(x)
dimnames(x)

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-2-9 12:23 , Processed in 0.019668 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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