| method.skeleton {methods} | R Documentation |
Create a Skeleton File for a New Method
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 function assigned in the same source file.
Usage
method.skeleton(generic, signature, file, external = FALSE)
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 |
signature |
the method signature, as it would be given to |
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 |
To write multiple method skeletons to one file, open the file
connection first and then pass it to method.skeleton() in
multiple calls.
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
|
Value
The file argument, invisibly, but the function is used for its side effect.
See Also
setMethod, package.skeleton
Examples
## Not run:
setClass("track", representation(x ="numeric", y="numeric"))
method.skeleton("show", "track") ## writes show_track.R
method.skeleton("Ops", c("track", "track")) ##writes "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)
## End(Not run)