Home > Blockchain >  Link to R6 method from separate package in help pages and pkgdown
Link to R6 method from separate package in help pages and pkgdown

Time:04-20

Cross posted from: https://community.rstudio.com/t/link-to-r6-method-from-separate-package-in-help-pages-and-pkgdown/134702

I'm currently writing an R package and would like to link to the help page for an R6 method in a separate package. The page I want to link to is here: https://mc-stan.org/cmdstanr/reference/model-method-sample.html, and there is an .Rd file for the method as well (https://github.com/stan-dev/cmdstanr/blob/master/man/model-method-sample.Rd). Finally, I can also access the help page from R directly with ?cmdstanr::`model-method-sample`.

However, when I try to add a link to my own help page using the normal link to another package syntax described here, [cmdstanr::`model-method-sample`], I get this error:

Warning: Link to unknown topic: cmdstanr::`model-method-sample`

I feel like there must be some way to link to this help page, given that it definitely exists and has an .Rd page, but I haven't found a solution yet. Has anyone else run into this problem or know the solution?

CodePudding user response:

I think you (or Roxygen) are using the wrong syntax for the link. According to Writing R Extensions, the Rd syntax should be:

\link[cmdstanr]{model-method-sample}

I'm not sure how to generate this from Roxygen, but it appears to work as-is if I put it in Roxygen comments.

If you want the link with different text, the syntax is

\link[cmdstanr:model-method-sample]{link text}
  • Related