This vignette demonstrates how to use Quarto (.qmd) files as vignettes in R packages. Quarto is the next-generation version of R Markdown, offering enhanced features and better integration with multiple programming languages.
Quarto offers several advantages over traditional R Markdown:
#| syntaxHere’s a basic example using the package:
Note
This is a callout block that highlights important information.
Tip
Quarto supports multiple types of callouts: note, tip, warning, important, and caution.
You can use the modern #| syntax for chunk options:
Figure 1: Example plot showing data distribution
Quarto supports theorem and proof environments that integrate with the callouty-theorem extension to render as styled callout blocks.
Definition 1 (Sample Mean) The sample mean of observations \(x_1, x_2, \ldots, x_n\) is:
\[\bar{x} = \frac{1}{n}\sum_{i=1}^{n} x_i\]
Theorem 1 (Unbiasedness of the Sample Mean) The sample mean \(\bar{x}\) is an unbiased estimator of the population mean \(\mu\):
\[E[\bar{x}] = \mu\]
Proof
Proof. By linearity of expectation: \[E[\bar{x}] = E\!\left[\frac{1}{n}\sum_{i=1}^{n} x_i\right] = \frac{1}{n}\sum_{i=1}^{n} E[x_i] = \frac{1}{n} \cdot n\mu = \mu. \qquad \square\]
Example 1 (Computing the Sample Mean) For the data \(\{1, 2, 3, 4, 5\}\): \[\bar{x} = \frac{1+2+3+4+5}{5} = 3\]
Quarto has excellent support for mathematical equations using LaTeX syntax:
Inline equation: \(E = mc^2\)
Display equation:
\[ \bar{x} = \frac{1}{n}\sum_{i=1}^{n} x_i \]
| Feature | R Markdown | Quarto |
|---|---|---|
| YAML | Standard | Enhanced |
| Chunks | {r, option=value} |
#| option: value |
| Publishing | Good | Excellent |
| Cross-refs | Limited | Native |
Quarto vignettes provide a modern, feature-rich way to document R packages. They integrate seamlessly with documentation systems and offer enhanced capabilities for technical documentation.
For more information, see: