method.skeleton(methods)
method.skeleton()所属R语言包:methods
Create a Skeleton File for a New Method
创建一个新方法的框架文件
译者:生物统计家园网 机器人LoveR
描述----------Description----------
This function writes a source file containing a call to setMethod to define a method for the generic function and signature supplied. By default the method definition is in line in the call, but can be made an external (previously assigned) function.
这个函数写一个源文件包含一个setMethod定义一个通用的功能和提供的签名方法的调用。默认情况下定义的方法是在呼叫,但可以使外部(先前分配)功能。
用法----------Usage----------
method.skeleton(generic, signature, file, external = FALSE, where)
参数----------Arguments----------
参数:generic
the character string name of the generic function, or the generic function itself. In the first case, the function need not currently be a generic, as it would not for the resulting call to setMethod.
泛型函数的字符串名称,或泛型函数本身。在第一种情况下,该功能需要目前没有一个通用的,因为它产生的呼叫setMethod。
参数:signature
the method signature, as it would be given to setMethod
签名的方法,因为它会给予setMethod
参数:file
a character string name for the output file, or a writable connection. By default the generic function name and the classes in the signature are concatenated, with separating underscore characters. The file name should normally end in ".R".
字符串为输出文件的名称,或一个可写的连接。默认情况下,通用的函数名和签名类串联,分离下划线字符。文件的名称一般应在".R"结束。
参数:external
flag to control whether the function definition for the method should be a separate external object assigned in the source file, or included in line in the call to setMethod. If supplied as a character string, this will be used as the name for the external function; by default the name concatenates the generic and signature names, with separating underscores.
标志控制函数定义的方法是否应该是一个独立的外部对象在源文件中分配,或包括在调用setMethod在线。如果作为一个字符串提供,这将被用来作为外部函数的名称;默认名称串连的通用和签名的名字,分离下划线。
参数:where
The environment in which to look for the function; by default, the top-level environment of the call to method.skeleton.
的环境中寻找的功能,默认情况下,调用method.skeleton顶级的环境。
值----------Value----------
The file argument, invisibly, but the function is used for its side effect.
file参数,无形之中,但该功能用于其副作用。
参见----------See Also----------
setMethod, package.skeleton
setMethod,package.skeleton
举例----------Examples----------
setClass("track", representation(x ="numeric", y="numeric"))
method.skeleton("show", "track") ## writes show_track.R[#写入show_track.R]
method.skeleton("Ops", c("track", "track")) ## writes "Ops_track_track.R"[#写入“Ops_track_track.R”]
## write multiple method skeletons to one file[#写一个文件的多个方法骨架]
con <- file("./Math_track.R", "w")
method.skeleton("Math", "track", con)
method.skeleton("exp", "track", con)
method.skeleton("log", "track", con)
close(con)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|