I would like to automatically generate documentation for my R functions and I've already come across the package roxygen2, which almost fulfills my needs. However, I would like to include in my documentation whole chunks of code without having to enclose them with #' '''. Practically speaking, in the example below I would like to automatically include
add <- function(x, y) {
x + y
}
in my "sum.rd" file as it is (i.e., without having to duplicate it in file "sum.R" and enclose it in #' ''').
Is there any way to achieve this?
file "sum.R":
#' Add together two numbers \
#' @param x A number \
#' @param y A number \
#' @return The sum of \code{x} and \code{y} \
#' @examples \
#' add(1, 1) \
#' add(10, 1) \
add <- function(x, y) { \
x + y \
}