Can I use a new line inside the roxygen2 code block?

I am wondering if it is possible to insert new lines inside code blocks in roxygen2 when documenting a function?

If I have something inside \code{} , roxygen2 by default collapses all newlines into separate spaces. I tried to insert \cr inside to ensure line breaks, and I get the desired behavior, but then I get a WARNING when I "R CMD CHECK". Is there any way to do this?

Example:

 #' \code{ #' multiple #' lines #' } 
+5
source share
1 answer

Use \preformatted instead of \code . \code for inline code (works like `` on SO), and \preformatted for shorthand blocks (for example, indentation on SO).

 #' \preformatted{ #' multiple #' lines #' } 

Note that the initial line break immediately after { will also be part of the code block, so you may need to delete it.

+9
source

All Articles