I am using devtools
to build R package, and there are some functions that are NOT designed to be visible to end-users. However, since these functions involve calling C codes by .Call
, so that I have to write @useDynLib
above the function for automatic generation of .Rd files. In that way, when I build the package, even I did NOT include the @export
for those functions, they nonetheless appear in the help document... Is there a way to suppress those functions even if they have been documented? Thanks!
Asked
Active
Viewed 3,708 times
16

alittleboy
- 10,616
- 23
- 67
- 107
-
1You only need one `useDynLib` declaration per package. – hadley Apr 09 '13 at 03:35
-
@hadley: thanks, I've corrected that...but still functions without `@ export` are in the help document, which I wish are invisible to end-users. Any method to "suppress" producing .Rd files? – alittleboy Apr 09 '13 at 03:38
-
1Don't use roxygen comments? – hadley Apr 09 '13 at 04:49
-
@hadley: I think in order to automatically update the NAMESPACE to include `@ useDynLib` I prefer to use roxygen2... Just curious how can I make the functions invisible to end-users (even if they have associated .Rd) Thanks ;-) – alittleboy Apr 09 '13 at 16:02
-
4Oh then you want `@keywords internal` – hadley Apr 10 '13 at 13:28
-
@hadley: thank you so much! that works perfectly -- I should read through your wiki pages on devtools as you wrote explicitly there ;-) – alittleboy Apr 10 '13 at 15:43
3 Answers
28
According to Hadley's comments, use @keywords internal
will make the function invisible to end-users. Details can be found here in the wiki pages of devtools
.

r2evans
- 141,215
- 6
- 77
- 149

alittleboy
- 10,616
- 23
- 67
- 107
11
The wiki linked in the accepted answer no longer discusses @keywords internal
(as of April 2016). In case it's helpful for someone to see an example:
# multiplyBy3
#' This is an example of an internal function called \code{multiplyBy3()}
#'
#' Sometimes you want internal functions as part of an R Package built with
#' RStudio and roxygen2, but you don't want .Rd files created for them
#' or to have them be visible in the help document following the build process
#'
#' @keywords internal
#'
#' @param base_num The number to multiply by three
#'
#' @import jsonlite
#'
#' @return Returns a numeric vector
#'
multiplyBy3 <- function(base_number) {
stopifnot(is.numeric(base_number))
return(base_number * 3)
}
Key bits: do not include @export
and do include @keywords internal

arvi1000
- 9,393
- 2
- 42
- 52
-
1This is what I was searching for the past half an hour. Thanks @arvi1000 – Veera Dec 04 '16 at 10:03
10
For me, @keywords internal
did not work (roxygen2 6.1.1). I was able to achieve the desired result using the following in my roxygen comments:
@noRd

shosaco
- 5,915
- 1
- 30
- 48