Bilingual reproducible reporting guide · 双语可复现报告指南

Build reports where code and story stay together.

让代码、分析与叙事始终同步。

Learn the essential R Markdown workflow—from YAML and executable chunks to controlled output, figures, and publication-ready tables with knitr::kable(). 从 YAML 与可执行代码块开始,掌握输出控制、图形,以及使用 knitr::kable() 制作清晰表格的完整工作流。

  • Self-paced
  • Runnable R examples
  • 中英双语

Learning path · 学习路径

From blank file to reproducible report.

Follow four connected stages, then return to any topic when your project needs it. 沿着四个相互衔接的阶段学习,也可以根据项目需要随时查阅单个主题。

  1. 01

    Compose · 编写

    Structure the document

    Combine YAML metadata, Markdown prose, headings, links, mathematics, and parameters in one plain-text source.

    Explore document anatomy
  2. 02

    Compute · 计算

    Make analysis executable

    Add named R chunks and inline expressions so results, plots, and narrative values update from the same analysis.

    See a worked analysis
  3. 03

    Control · 控制

    Direct knitr

    Use chunk options to decide what runs, what appears, how figures render, and when caching is safe.

    Study chunk options
  4. 04

    Present · 呈现

    Build readable tables

    Turn data frames and summaries into portable tables with captions, labels, alignment, rounding, and safe HTML.

    kable() in depth

Choose your edition · 选择语言

One curriculum, two complete guides.

Both editions follow the same practical sequence and contain the same runnable examples. Choose the language that lets you focus on the ideas. 两个版本采用相同的学习顺序和可运行示例,请选择最适合你的语言。

Complete guide Self-paced

English edition

R Markdown: A Practical Guide to knitr and kable()

Build a reproducible report from first principles, then go deeper into code execution, caching, table output, and dependable rendering.

  • YAML & Markdown
  • Chunk options
  • Inline R
  • Figures
  • kable() tables
  • Reproducibility
Open the English guide
完整教程 自主学习

中文版本

R Markdown 主要用法:knitr 与 kable() 详解

从基础结构开始创建可复现报告,再深入学习代码执行、缓存、表格输出与可靠渲染。

  • YAML 与 Markdown
  • 代码块选项
  • 行内 R
  • 图形输出
  • kable() 表格
  • 可复现性
打开中文教程

Choose a path · 按目标学习

Start with the route that fits your work.

You do not need to read every section in order. Choose a route, solve the task in front of you, then return for more depth. 无需按顺序读完全部内容;先选择符合当前目标的路线,再按需要继续深入。

Key concepts · 核心概念

Four pieces, one publishing workflow.

Each tool has a distinct job. Understanding those boundaries makes reports easier to debug, reuse, and share. 每个工具各司其职;理解这些边界,会让报告更容易调试、复用与分享。

  1. 01 R Markdown The source · 源文件
  2. 02 knitr The engine · 执行引擎
  3. 03 Pandoc The converter · 格式转换
  4. 04 HTML The deliverable · 最终成果

One source of truth

Keep explanation, code, and output instructions together so every render starts from the same documented analysis.

Intentional execution

knitr evaluates chunks in order and captures their text, tables, messages, and figures for the next stage.

A function, not a package

kable() is a table-formatting function exported by knitr. The full name is knitr::kable().

Portable output

Pandoc converts the intermediate document into HTML, Word, PDF, or another format selected in YAML.