Linking to an S4 method in a .rd file?

I'm writing a package with an S4 class, and I've written methods for as.POSIXct and as.POSIXlt for the class. I've written the documentation and everything looks fine, except that I would like to reference 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 that is only supposed to be put in the \usage section, which isn't where I want it. Is there a way to do this? It seems odd to me that it would not be allowed.

I realize that it is possible to combine these .rd files and avoid this issue, but I'm trying to learn as much as possible about classes and packages in R, so this is of interest to me 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")}}{
~~more description of function~~
}
}}
\keyword{methods}


The line fourth from the bottom is the one that is causing problems.

-

The basic format for a link is

\link{foo}


where foo appears in some help page (in the same package) as \alias{foo}. So if your other package has \alias{as.POSIXlt,abc-method} (pay attention to 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, rather than, e.g., an alias). Adding \code{} is mark-up, so not directly relevant to establishing a link. The link above inserts "as.POSIXlt,abc-method" into the help page, which might be more informative (or not) than an arbitrary \alias tag that might be present.

-
Didn't realize that R was that specific about the aliases. Thank you! –  Liz Sander Aug 21 '12 at 15:28

Per the Cross-references section of Writing R extensions, you can create links to other help pages like this:

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


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

-
Seconding, I don't think there's another way. –  themel Aug 20 '12 at 19:28
I appreciate it! I read that section of WRE but I was a little confused, and I wasn't sure if it would work for what I wanted. Your explanation was very clear, thank you! –  Liz Sander Aug 20 '12 at 19:30
Actually, the Cross-references section is probably more appropriate. I will edit. –  GSee Aug 20 '12 at 19:31
Actually, I'm getting a "missing link" warning when I run R CMD check. It's definitely not happy with the link I added. I think it must work differently for S4 methods... I thought specifying the package was what I needed to add, but apparently not. –  Liz Sander Aug 20 '12 at 19:39
does it work if you just do \code{\link{as.POSIXct}}? Otherwise, you'll need to show more of you .Rd file –  GSee Aug 20 '12 at 19:43
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.6456308960914612, "perplexity": 1689.1331467548039}, "config": {"markdown_headings": false, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 5, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2014-10/segments/1393999655041/warc/CC-MAIN-20140305060735-00012-ip-10-183-142-35.ec2.internal.warc.gz"}