[R] Documenting S4 Methods

Dario Strbenac D.Strbenac at garvan.org.au
Wed Aug 25 05:00:03 CEST 2010


I'm in the process of converting some S3 methods to S4 methods.

I have this function :

setGeneric("enrichmentCalc", function(rs, organism, seqLen, ...){standardGeneric("enrichmentCalc")})

setMethod("enrichmentCalc", c("GenomeDataList", "BSgenome"), function(rs, organism, seqLen, ...) {
         ...          ...             ...
})

setMethod("enrichmentCalc", c("GenomeData", "BSgenome"), function(rs, organism, seqLen=NULL, do.warn=FALSE) {
       ...            ...             ...
})

setMethod("enrichmentCalc", c("GRanges", "BSgenome"), function(rs, organism, seqLen=NULL) {
       ...            ...             ...
}

and a part of my Rd file is :

\name{enrichmentCalc}
\docType{methods}
\alias{enrichmentCalc,GenomeDataList,BSgenome-method}
\alias{enrichmentCalc,GenomeData,BSgenome-method}
\alias{enrichmentCalc,GRanges,BSgenome-method}
...                ...                   ...
\usage{
  enrichmentCalc(rs, organism, seqLen, ...)
  enrichmentCalc(rs, organism, seqLen=NULL, do.warn=FALSE)
  enrichmentCalc(rs, organism, seqLen=NULL)
}
...                ...                    ...

Can anyone suggest why I'm seeing this error :

* checking for code/documentation mismatches ... WARNING
Codoc mismatches from documentation object 'enrichmentCalc':
enrichmentCalc
  Code: function(rs, organism, seqLen, ...)
  Docs: function(rs, organism, seqLen = NULL, do.warn = FALSE)
  Argument names in code not in docs:
    ...
  Argument names in docs not in code:
    do.warn
  Mismatches in argument names:
    Position: 4 Code: ... Docs: do.warn
  Mismatches in argument default values:
    Name: 'seqLen' Code:  Docs: NULL
enrichmentCalc
  Code: function(rs, organism, seqLen, ...)
  Docs: function(rs, organism, seqLen = NULL)
  Argument names in code not in docs:
    ...
  Mismatches in argument default values:
    Name: 'seqLen' Code:  Docs: NULL

* checking Rd \usage sections ... WARNING
Objects in \usage without \alias in documentation object 'enrichmentCalc':
  enrichmentCalc

Also, what is the difference between

...          ...          ...
\docType{methods}
...          ...          ...
\alias{methodName,class-method}
...          ...          ...
\usage{methodName(arg1)}
...          ...          ...

and

...          ...          ...
\alias{methodName,class-method}
...          ...          ...
\usage
{
    \S4method{methodName}{class}(arg1)
}
...          ...          ...

I've seen both ways used for S4 methods and don't know what is the underlying difference.

I haven't been able to find any good tutorials for the new S4 architecture (written post 2006), so I'm not sure where to start with S4.

Thanks,
       Dario.

--------------------------------------
Dario Strbenac
Research Assistant
Cancer Epigenetics
Garvan Institute of Medical Research
Darlinghurst NSW 2010
Australia



More information about the R-help mailing list