Preserving indentation in examples section

Roxygen have made my work a lot easier and is in most cases nice and intuitive. One thing that I have never figured out though is how to preserve indentation in @examples sections so that the result of roxygenize("myPackage") containing

#' @examples
#' sapply(1:10, function(i){
#'     x <- rbind(matrix(rnorm(20), 10, 2),
#'                matrix(rnorm(20), 10, 2) + i)
#'     myFunc(x)
#' }

would be

examples{sapply(1:10, function(i){
    x <- rbind(matrix(rnorm(20), 10, 2),
               matrix(rnorm(20), 10, 2) + i)
    myFunc(x)
}}

instead of

examples{sapply(1:10, function(i){
x <- rbind(matrix(rnorm(20), 10, 2),
matrix(rnorm(20), 10, 2) + i)
myFunc(x)
}}

It is a small detail but it makes all but the simplest examples unnecessarily hard to read so I'd appreciate it if someone can help me.

Edit: This bug was corrected in later versions of roxygen.


简短示例的开销可能太大,但对于更长的示例,您可以使用@example relative/path/to/example来拉取文件,这应该会得到缩进权限。

链接地址: http://www.djcxy.com/p/54216.html

上一篇: 如何检查变量是否是Python中的字典

下一篇: 在示例部分中保留缩进