Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple functions in one .Rd file
    text
    copied!<p><strong>Short version</strong>: Can I emulate the documentation of <code>Normal</code> in package <code>stats</code> using <code>roxygen</code>?</p> <p><strong>Long version</strong>: I'm working on a package and was trying make the documentation more readable by having a number of functions with common inputs/parameters collected under one heading, which will be a generic reference to the group. Each function should still be available to the end user independently. </p> <p>I took as inspiration the documentation for <code>Normal</code> which gives a number of methods related to the normal distribution e.g. <code>stats::dnorm()</code>. </p> <p>When I search <code>?dnorm</code> I find the name of the help section is <code>Normal</code> even though <code>Normal</code> does not appear to be an exported function or object.</p> <p>What I've tried is putting the following into <code>funs.R</code>:</p> <pre><code>##' @rdname funs ##' @name funs ##' @aliases sum1 ##' @aliases prod1 ##' @title Two functions ##' @param x X ##' @param y Y ##' @return sum1 returns x+y ##' \cr ##' prod1 returns x*y ##' @examples ##' sum1(3,4) ##' prod1(3,4) ##' @export sum1 &lt;- function(x,y) x+y ##' @export ##' @rdname funs prod1 &lt;- function(x,y) x*y </code></pre> <p>I then run <code>roxygen2</code> on the above. The difficulty is that when running <code>R CMD check</code> on this minimal package, it finds the package cannot be loaded as <code>undefined exports: funs</code>. If I remove the line <code>##' @name funs</code> the package passes <code>R CMD check</code> but the name of the help section is <code>sum1</code> rather than <code>funs</code>. If I add the following below the examples section:</p> <pre><code>##' @export funs &lt;- function(x) x </code></pre> <p>It passes and I can see the help formatted as I would like, but I'm exporting a meaningless function in order to get the name to display correctly. </p> <p>I tried looking in the source help files for <code>stats</code> to see how it was achieved, but they are in <code>.Rdx</code> format which I'm not sure how to display. </p> <p>Also, on a related note, does what sort of thing <em>is</em> <code>Normal</code>?</p> <pre><code>require(stats) getAnywhere("Normal") &gt; no object named 'Normal' was found </code></pre> <hr> <p><strong>Update:</strong></p> <p>@TylerRinker - I'm afraid this was the first thing I had tried. This combines the functions into one <code>.Rd</code> file but the name of the associated help is the same as the name of the first function, which is what I was trying to avoid:</p> <pre><code>##' sum ##' gives the sum ##' @param x X ##' @param y Y ##' @return sum1 returns x+y ##' @examples ##' sum1(3,4) ##' @rdname funs ##' @export sum1 &lt;- function(x,y) x+y ##' product ##' gives the product ##' @return prod1 returns x*y ##' @examples ##' prod1(3,4) ##' @rdname funs ##' @export prod1 &lt;- function(x,y) x*y </code></pre> <p>@Andrie - this solution causes exactly the same difficulty, the name of the help is the same as the first function.</p> <p>Perhaps this just isn't possible... </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload