Link to S4 method in .rd file?

I am writing a package with the S4 class, and I have written methods for as.POSIXct and as.POSIXlt for the class. I wrote the documentation and everything looks great, except that I would like to refer to the as.POSIXct method in the documentation for as.POSIXlt and vice versa. I tried \S4method{coerce}{abc, POSIXct}(from, to) , (where "abc" is the S4 class), but this should be placed in the \usage section, which is not where I want it. Is there any way to do this? It seems strange to me that this is not permissible.

I understand that you can combine these .rd files and avoid this problem, but I try to learn as much as possible about the classes and packages in R, so I'm interested in it anyway.

Here is the skeleton of one of the .Rd files:

 \name{as.POSIXct-methods} \docType{methods} \alias{as.POSIXct-methods} \alias{as.POSIXct,ANY-method} \alias{as.POSIXct,abc-method} \title{\code{abc} Method for Function \code{as.POSIXct}} \description{ \code{as.POSIXct} method to coerce timestamps in \code{abc} objects into \code{POSIXct} format. } \section{Methods}{ \describe{ ~~description here~~ \item{\code{signature(x = "ANY")}}{ default implementation (from base) } \item{\code{signature(x = "abc")}}{ implementation for \code{\link{abc}} objects. ~~more description of function~~ See \code{\linkS4class{abc}} for more about abc objects. See also \code{\link[abc]{as.POSIXlt}} for the corresponding \code{POSIXlt} method. } }} \keyword{methods} 

The fourth line from the bottom is the problem that causes the problems.

+4
source share
2 answers

Basic link format

 \link{foo} 

where foo appears on some help page (in the same package) as \alias{foo} . Therefore, if your other package has \ alias {as.POSIXlt, abc-method} (note the absence of spaces), then

 \link{as.POSIXlt,abc-method} 

Adding [abc] is only necessary when linking to other packages, and then the semantics are confusing (in \link[abc]{foo} , foo is the name of the HTML help page, and not, for example, an alias). Adding \code{} is markup, so it is not directly related to linking. The link above inserts "as.POSIXlt, abc-method" into the help page, which may be more informative (or not) than any \ alias tag that may be present.

+2
source

In the Cross-References section of the Writing R extension, you can create links to other help pages, for example:

 \code{\link[base]{as.POSIXct}} 

Where "base" is the name of the package (I don’t think that [base] is necessary, but if it were a different package, it would be)

+2
source

All Articles