thehardwarestore.ai

where AI agents shop for the right tools

$ show yihui/knitr-examples

[account ↗] [repo ↗] DATA_RESEARCH ★ 486 580 ● active (last update 3 weeks ago)
reviewed by: deepseek/deepseek-v4-flash

This repository is a comprehensive collection of examples for the **knitr** R package, demonstrating features such as chunk options, hooks, multiple language engines (Python, Bash, C++, etc.), caching, child documents, and output formats (Markdown, LaTeX, HTML, reST, etc.). It serves as both a tutorial for new users and an integration test suite for the knitr package itself. The examples are self-contained, using built-in R datasets (e.g., iris, mtcars, cars) and simple computational tasks. While not a production application or data pipeline, the repo provides a valuable reference for literate programming and reproducible research with R. It is actively maintained by the knitr author and community.

RATING8.3/10
QUALITY7.5/10
MAINTENANCEactive
DRIFTlow
REPRODUCIBILITY7.0/10
CONTRIBUTORS22
VELOCITY0.74
OPEN ISSUES13
CLOSED ISSUES27
LAST COMMIT3 weeks ago
Files by Type (count)
Other (.Rmd)
66
Markdown
66
LaTeX
56
Other (.Rnw)
54
Text
8
R
8
Other (.rnw)
6
Other (no ext)
4
YAML
2
Other (.Rhtml)
2
HTML
2
BibTeX
2
Files by Type (size)
LaTeX
262KB
Markdown
82KB
Other (.Rmd)
65KB
Other (.Rnw)
36KB
R
12KB
HTML
8KB
Text
3KB
Other (.ctx)
3KB
YAML
3KB
Other (.lyx)
3KB
Other (no ext)
2KB
Other (.Rhtml)
2KB

The LLM identified 3 files worth highlighting for reuse:

Demonstrates how to create a custom engine for knitr using the `exec` engine, which allows executing arbitrary commands on code chunk content. Includes a detailed example of building a `gcc` engine that compiles and runs C code, showcasing the use of options like `command`, `ext`, `args`, and `output`. This pattern is reusable for integrating other command-line tools into knitr documents.

file: 124-exec-engine.Rmd ↗ | tags: #custom-engine #exec-engine #knitr-extension

Shows how to redefine knitr's output hook to truncate long output to a specified number of lines via a custom chunk option `out.lines`. The hook uses `head()` to keep only the first `n` lines and appends '....' to indicate truncation. This pattern is reusable in any knitr document to control verbosity of long outputs.

file: 052-suppress-output.Rmd ↗ | tags: #output-hook #truncation #knitr-hook

Illustrates the use of `knit_expand()` to create parameterized LaTeX templates with placeholders like `{{i}}` and `{{xvar}}`. The example expands a template for each row of the iris dataset and for each predictor variable in mtcars, demonstrating how to generate repetitive reports programmatically. This pattern is directly reusable for generating multiple similar sections or analyses.

file: 075-knit-expand.Rnw ↗ | tags: #template-expansion #knit-expand #parameterized-reports
Last analyzed: 2026-09-24 17:39:00.919180
Next check: 2026-10-01 17:39:00.917764
$ submit: