Search code examples
rfunctionknitrquarto

R: Including help of a function into Quarto document


The following code gives the output

example(
    topic          = mean
  , package        = "base"
  , type           = "html"
  )

enter image description here

Wondering how to add similar kind colored output in document.

My attempt and its output is below:

---
title: "Help"
format: html
---


```{r}
#| echo: false
example(
    topic          = mean
  , package        = "base"
  , type           = "html"
  )
```

enter image description here


Solution

  • To get syntax highlighting, you may use class-output: r,

    ---
    title: "Help"
    format: html
    ---
    
    
    ```{r}
    #| echo: false
    #| class-output: r
    
    example(
        topic          = mean
      , package        = "base"
      , type           = "html"
      )
    ```
    

    colored help output