我有一个功能正在尝试使用roxygen2进行记录:

#' Name of function
#'
#' Description
#'
#' @param x The input data
#' @param method one of:
#' "method1" - very long text here
#' "method2" - very long text here
#' "method3" - very long text here
#' "method4" - very long text here
#' "method5" - very long text here
#' "method6" - very long text here
#' "method7" - very long text here
#' "method8" - very long text here
#' "method9" - very long text here
#' "method10" - very long text here
myfun <- function (x, method){return(NULL)}

此功能有大约10种不同的方法,每种方法都有很长的描述。我希望每个“方法”之间都有一个换行符,以使快速查看可用的不同方法变得容易。

如所写,当我调用roxygenize('mypackage')时,上面的文本被压缩为一行。

如何手动将换行符插入roxygen2文档?

最佳答案

这有效:

#' Name of function
#'
#' Description
#'
#' @param x The input data
#' @param method one of: \cr
#' "method1" - very long text here \cr
#' "method2" - very long text here \cr
#' "method3" - very long text here \cr
#' "method4" - very long text here \cr
#' "method5" - very long text here \cr
#' "method6" - very long text here \cr
#' "method7" - very long text here \cr
#' "method8" - very long text here \cr
#' "method9" - very long text here \cr
#' "method10" - very long text here \cr
myfun <- function (x, method){return(NULL)}

这是我使用\cr的仓库中的实际示例:https://github.com/trinker/SOdemoing/blob/master/R/FUN.R

@Gregor的评论也很受好评。看起来像:
#' @param method2 one of:
#' \itemize{
#'   \item method1 - very long text here
#'   \item method2 - very long text here
#'   \item method3 - very long text here
#'   \item method4 - very long text here
#'   \item method5 - very long text here
#'   \item method6 - very long text here
#'   \item method7 - very long text here
#'   \item method8 - very long text here
#'   \item method9 - very long text here
#'   \item method10 - very long text here
#' }

在这里,您可以看到两者的输出:

我创建了一个GitHub repo, SOdemoing,以测试类似这样的事情(与软件包有关的更详尽的问题和答案)。请参见FUN.R,在这里我使用roxygen2测试这两种方法,然后在我设置了resulting help manual的位置(同样,该功能是FUN.R)。

关于r - roxygen2手动插入换行符,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18835365/

10-12 20:50