Skip to content
Back to skills

Knitr

ASecurity

R knitr package for dynamic report generation. Use for literate programming and chunk options.

  • 5 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added June 5, 2026
datagit

Security analysis

A100/100

Scanned June 5, 2026

npx -y skills add LeoLin990405/r-analytics-skill --skill knitr --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Knitr?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Knitr
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/leolin990405-knitr/badge)](https://www.skillsdirectory.com/skills/leolin990405-knitr)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: knitr
description: R knitr package for dynamic report generation. Use for literate programming and chunk options.
---

# knitr Package

Dynamic report generation engine.

## Global Options

```r
knitr::opts_chunk$set(
  echo = TRUE,
  message = FALSE,
  warning = FALSE,
  fig.width = 8,
  fig.height = 6,
  fig.path = "figures/",
  cache = TRUE,
  cache.path = "cache/"
)
```

## Chunk Options

```r
# Display
echo = TRUE/FALSE      # Show code
eval = TRUE/FALSE      # Run code
include = TRUE/FALSE   # Include in output
results = "markup"/"asis"/"hide"/"hold"

# Figures
fig.width = 7
fig.height = 5
fig.cap = "Caption"
fig.align = "center"/"left"/"right"
out.width = "80%"
dev = "png"/"pdf"/"svg"

# Caching
cache = TRUE
cache.lazy = TRUE
dependson = "chunk-name"
```

## Tables

```r
knitr::kable(df, caption = "My Table")

knitr::kable(df,
  format = "html",
  digits = 2,
  col.names = c("A", "B", "C"),
  align = c("l", "c", "r")
)
```

## Include External

```r
# Read external code
knitr::read_chunk("external.R")

# Include child document
```{r child = "child.Rmd"}
```

# Include graphics
knitr::include_graphics("image.png")
```

## Hooks

```r
# Custom chunk hook
knitr::knit_hooks$set(
  time = function(before, options) {
    if (before) {
      start_time <<- Sys.time()
    } else {
      paste("Time:", Sys.time() - start_time)
    }
  }
)
```

## Spin

```r
# Convert R script to Rmd
knitr::spin("script.R")

# In script.R use:
#' # Title
#' Some text
#+ chunk-name, echo=FALSE
code_here()
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.