Reputation: 1364
Is it possible to get a code chunk tidy
ed up, while leaving the comments alone?
Say I wanna put ASCII art in some comments in a function, I could just set tidy = F
but then the rest of the code chunk is "messy" as in the following output:
myfun=function(a,b){
## ^_^
## {o,o}
## |)__)
##-----m-m-----
c=sum(a,b)
return(c)
}
If I set tidy = T
then the short comments all wrap together and I get the following as output:
myfun = function(a, b) {
## ^_^ {o,o} |)__) -----m-m-----
c = sum(a, b)
return(c)
}
What I would like to see is the following as output:
myfun = function(a, b) {
## ^_^
## {o,o}
## |)__)
## -----m-m-----
c = sum(a, b)
return(c)
}
Upvotes: 4
Views: 445
Reputation: 1364
As suggested in the comments, I'll answer my own question.
If one looks at Yihui's documentation for formatR
, one might notice that roxygen comments (which look like this: #'
) will not be wrapped in any case.
So using the code chunk
```{r, tidy = T}
myfun=function(a,b){
#' ^_^
#' {o,o}
#' |)__)
#'-----m-m-----
c=sum(a,b)
return(c)
}
```
will give me the desired output:
myfun = function(a, b) {
#' ^_^
#' {o,o}
#' |)__)
#'-----m-m-----
c = sum(a, b)
return(c)
}
Upvotes: 6