我有一个函数我想用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文档中手动插入换行符?
答案 0 :(得分:30)
这有效:
#' 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)。