Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to document arguments in functions which are not exported in R package?

Tags:

r

devtools

I am using the devtools package to check if a package I am developing is ready for submission to CRAN.

Using Roxygen2 through devtools, I documented a small number of functions with #'@export, in order for them to be available when the package I am developing is loaded.

However, when I run devtools::check(), it seems I need to document the functions that are NOT exported, i.e. those that may be called by a function which is exported, but which are not available nor needed by whoever uses the package. Here is an example from the output of devtools::check():

checking Rd \usage sections ... WARNING
Undocumented arguments in documentation object 'calculate_agreement'
  ‘a_assign_star’ ‘a_assign’

Do I need to document those arguments although the function is not exported?

like image 968
Joshua Rosenberg Avatar asked Dec 31 '16 19:12

Joshua Rosenberg


People also ask

How do I add documents in R?

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.

What is RD file in R?

R objects are documented in files written in “R documentation” (Rd) format, a simple markup language much of which closely resembles (La)TeX, which can be processed into a variety of formats, including LaTeX, HTML and plain text.


1 Answers

I believe the problem here (based on past experience) is that you are probably using Roxygen comment delimiters #' in the preamble to the function. This (I'm pretty sure) triggers the creation of a .Rd file (and the need to document parameters), whether or not you have an @export directive or not. My solution in this case was to use regular # commenting rather than #'.

Based on this answer it's possible that an explicit @keywords internal directive would also work (but I haven't tried it).

like image 155
Ben Bolker Avatar answered Oct 13 '22 10:10

Ben Bolker