[R] documenting s4 methods in package

Thomas Lumley tlumley at u.washington.edu
Tue Apr 4 16:13:26 CEST 2006


On Tue, 4 Apr 2006, Steven Lacey wrote:

> Hi,
>
> I have written a package that contains many s4 generic functions and
> associated methods. I am having a lot of trouble getting R to build the help
> pages for these generic functions without reporting, "missing link(s):
> ~~fun~~, which means that it cannot find the appropriate function when code
> in the example section of the help is run. Right?

No.  It means that you still have \link{~~fun~~} in the \seealso 
section.

 	-thomas


> After some playing around I can get it to build the help without missing a
> link, but often I am not sure what I have done to correct the "problem" and
> it takes a lot of time.
>
> For instance, I had the package build the help without missing a function
> link. I then added a argument to two different functions and updated the
> corresponding .rd help files and now when R build the help pages it reports
> "missing link(s):  ~~fun~~. What is going on?
>
> Below is the code from the help file and the associated s4 method.
>
> Any help would be greatly appreciated.
>
> Steve
>
> GENERIC FUNCTION AND METHODS
>
> setGeneric("getRemovedDf.OAD",function(x,y,z,simplify=TRUE,descrip=FALSE){st
> andardGeneric("getRemovedDf.OAD")})
>
> setMethod("getRemovedDf.OAD","status.or.rm.v1",
>    function(x,y,z,simplify,descrip){
>        if(length(0">x at removed) <mailto:x at removed)> >0){
>            pred <- unlist(lapply(x at removed,function(x)x[1]))
>            resp <- unlist(lapply(x at removed,function(x)x[2]))
>            out  <- data.frame(pred,resp)
>            names(out) <- c(y,z)
>            return(out)
>        } else {
>            return(data.frame())
>        }
>    }
> )
>
> setMethod("getRemovedDf.OAD","sa",
>    function(x,y,z,simplify,descrip){
>        i <- unlist(lapply(x at outlier.removal,function(x)length(x at removed)))
>        if(all(i==0)){
>            return(list())
>        } else {
>            if(simplify) x at outlier.removal[seq(along=i)[i==0]]
> <mailto:x at outlier.removal[seq(along=i)[i==0]]<-NULL> <-NULL
>            tmp <-
> lapply(x at outlier.removal,getRemovedDf.OAD,x at predictorName,x at responseName)
>            if(descrip){
>                f <- as.data.frame(descrip[!"history"%in%names(x at descrip)])
>                return(lapply(tmp,function(x)cbind(f,x)))
>            } else {
>                return(tmp)
>            }
>        }
>    }
> )
>
>
> MAN FILE
> \name{getRemovedDf.OAD}
> \alias{getRemovedDf.OAD}
> %- Also NEED an '\alias' for EACH other topic documented here.
> \title{ ~~function to do ... ~~ }
> \description{
>  ~~ A concise (1-5 lines) description of what the function does. ~~
> }
> \usage{
> getRemovedDf.OAD(x, y, z, simplify = TRUE, descrip=FALSE)
> }
> %- maybe also 'usage' for other objects documented here.
> \arguments{
>  \item{x}{ ~~Describe \code{x} here~~ }
>  \item{y}{ ~~Describe \code{y} here~~ }
>  \item{z}{ ~~Describe \code{z} here~~ }
>  \item{simplify}{ ~~Describe \code{simplify} here~~ }
>  \item{descrip}{ ~~Describe \code{descrip} here~~ }
> }
> \details{
>  ~~ If necessary, more details than the __description__  above ~~
> }
> \value{
>  ~Describe the value returned
>  If it is a LIST, use
>  \item{comp1 }{Description of 'comp1'}
>  \item{comp2 }{Description of 'comp2'}
>  ...
> }
> \references{ ~put references to the literature/web site here ~ }
> \author{ ~~who you are~~ }
> \note{ ~~further notes~~ }
>
> ~Make other sections like Warning with \section{Warning }{....} ~
>
> \seealso{ ~~objects to See Also as \code{\link{~~fun~~}}, ~~~ }
> \examples{
> ##---- Should be DIRECTLY executable !! ----
> ##-- ==>  Define data, use random,
> ##--    or do  help(data=index)  for the standard data sets.
>
> ## The function is currently defined as
> function(x,y,z,simplify=TRUE,descrip=FALSE){standardGeneric("getRemovedDf.OA
> D")}
> }
> \keyword{ ~kwd1 }% at least one, from doc/KEYWORDS
> \keyword{ ~kwd2 }% __ONLY ONE__ keyword per line
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle




More information about the R-help mailing list