Rev 82871 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/methods/man/method.skeleton.Rd% Part of the R package, https://www.R-project.org% Copyright 1995-2016 R Core Team% Distributed under GPL 2 or later\name{method.skeleton}\alias{method.skeleton}\title{Create a Skeleton File for a New Method}\description{This function writes a source file containing a call to\code{\link{setMethod}} to define a method for the generic functionand signature supplied. By default the method definition is in linein the call, but can be made an external (previously assigned) function.}\usage{method.skeleton(generic, signature, file, external = FALSE, where)}\arguments{\item{generic}{the character string name of the generic function, orthe generic function itself. In the first case, the functionneed not currently be a generic, as it would not for theresulting call to \code{\link{setMethod}}.}\item{signature}{the method signature, as it would be given to \code{\link{setMethod}}}\item{file}{a character string name for the output file, or awritable connection. By default the generic function name andthe classes in the signature are concatenated, with separatingunderscore characters. The file name should normally end in \code{".R"}.To write multiple method skeletons to one file, open the fileconnection first and then pass it to \code{method.skeleton()} inmultiple calls.}\item{external}{flag to control whether the function definition forthe method should be a separate external object assigned in thesource file, or included in line in the call to\code{\link{setMethod}}.If supplied as a character string, this will be used as the namefor the external function; by default the name concatenates thegeneric and signature names, with separating underscores.}\item{where}{The environment in which to look for the function; by default,the top-level environment of the call to \code{method.skeleton}.}}\value{The \code{file} argument, invisibly, but the function is used for its side effect.}\seealso{\code{\link{setMethod}}, \code{\link{package.skeleton}}}\examples{\dontshow{oWD <- setwd(tempdir())}setClass("track", slots = c(x ="numeric", y="numeric"))method.skeleton("show", "track") ## writes show_track.Rmethod.skeleton("Ops", c("track", "track")) ## writes "Ops_track_track.R"## write multiple method skeletons to one filecon <- file("./Math_track.R", "w")method.skeleton("Math", "track", con)method.skeleton("exp", "track", con)method.skeleton("log", "track", con)close(con)\dontshow{setwd(oWD)}}\keyword{programming}\keyword{methods}