Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking to other packages in documentation in roxygen2 in R

I am wondering it there exists a method to link to function from other package when I'm trying to write a documentation for new package using roxygen2. Something like \link{pck=PACKAGE_NAME, fun=FUNCTION_NAME}?

like image 415
Marcin Kosiński Avatar asked Aug 25 '14 15:08

Marcin Kosiński


People also ask

How do I write R package documents?

To add documentation to an R package, you need to create a subdirectory “ man ” containing a set of files, one per function, in a special R Documentation format ( . Rd ). These will be the source for the documentation for each function; R processes them to create plain text, PDF, and HTML versions.

How do I add comments to Roxygen?

But you can add an ROxygen2 skeleton for a function by placing your cursor inside the function then pressing ctr+alt+shift+R . Then if you hit enter in the ROxygen2 codeblock it will automatically add the backtick.

Do R packages contain documentation?

R packages contain code, data, and documentation in a standardised collection format that can be installed by users of R, typically via a centralised software repository such as CRAN (the Comprehensive R Archive Network).


2 Answers

You have to type \link[pkg]{function} e.g. \link[stringi]{stri_c}

like image 93
potockan Avatar answered Sep 19 '22 22:09

potockan


Roxygen2 now also supports documentation written in markdown.

The markdown syntax is for the link is [foo::bar()] which is translated to \code{\link[foo:bar]{foo::bar()}} in the generated .Rd file. (See Roxygen2 vignette.)

Note that you may need to specifically turn on Markdown support by writing Roxygen: list(markdown = TRUE) in your DESCRIPTION file, or by putting an #' @md comment if you want to enable markdown only for a specific man page. This is also explained at the very top of the linked vignette. (Thanks to @Tjebo for the comment)

Note that there are two colons in the markdown version whereas there is only one colon in the Rd version.

like image 32
cbeleites unhappy with SX Avatar answered Sep 22 '22 22:09

cbeleites unhappy with SX