R Roxygen2: How to document a function generated by another function?

In my package, I wrote a functional that takes a function as input and creates another function. How can I document a function created with a procedure like this?

Below is an illustration: use a function to convert sin()

(which takes a radian input) to sind()

which takes input in degree units.

rad2deg <- function(f) {
  force(f)
  function(x) f(x / 180 * pi)
}

      

Here is some documentation for the function below ...

sind <- rad2deg(sin)

      

rad2deg

- this is just my service functionality, used only by me and, therefore, not exported and not documented. I need to export sind

. But I have no idea how this can be done as it is not even recognized as a function, and it does not even have an explicit argument (of course it takes a function argument implicitly sin

). Thus, even the tag @param

cannot be used.

Does anyone have any ideas?

+3


source to share


1 answer


It works. The following code generates an Rd file and a NAMESPACE directive for the function sind

.



rad2deg <- function(f) {
  force(f)
  function(x) f(x / 180 * pi)
}

#' sin for degrees
#' @param x an angle in degrees
#' @return sin(x)
#' @export
sind <- rad2deg(sin)

      

+1


source







All Articles