<commit_before>---
layout: default
title: Minimal examples
subtitle: Examples for LaTeX, GFM and HTML
category: demo
---

For beginners, it is probably a good idea to start with some minimal examples; here I provide three examples for LaTeX, GFM (GitHub Flavored Markdown) and HTML, respectively.

- LaTeX
  - Rnw source: [knitr-minimal.Rnw](https://github.com/yihui/knitr/blob/master/inst/examples/knitr-minimal.Rnw)
  - PDF output: [knitr-minimal.pdf](https://github.com/downloads/yihui/knitr/knitr-minimal.pdf)
- GFM
  - md source: [knitr-minimal\_knit\_.md](https://github.com/yihui/knitr/blob/master/inst/examples/knitr-minimal_knit_.md)
  - output: [knitr-minimal.md](https://github.com/yihui/knitr/blob/master/inst/examples/knitr-minimal.md) (GitHub does the job of parsing the md file to HTML)
- HTML
  - html source: [knitr-minimal\_knit\_.html](https://github.com/yihui/knitr/blob/master/inst/examples/knitr-minimal_knit_.html)
  - output: [knitr-minimal.html](https://github.com/downloads/yihui/knitr/knitr-minimal.html)

Except the GFM demo, you can directly use `knit()` to knit the input file, e.g.,

{% highlight r %}
library(knitr)
knit('knitr-minimal.Rnw')
knit('knitr-minimal_knit_.html')
{% endhighlight %}<commit_msg>the gfm demo source is under raw instead of blob<commit_after>---
layout: default
title: Minimal examples
subtitle: Examples for LaTeX, GFM and HTML
category: demo
---

For beginners, it is probably a good idea to start with some minimal examples; here I provide three examples for LaTeX, GFM (GitHub Flavored Markdown) and HTML, respectively.

- LaTeX
  - Rnw source: [knitr-minimal.Rnw](https://github.com/yihui/knitr/blob/master/inst/examples/knitr-minimal.Rnw)
  - PDF output: [knitr-minimal.pdf](https://github.com/downloads/yihui/knitr/knitr-minimal.pdf)
- GFM
  - md source: [knitr-minimal\_knit\_.md](https://github.com/yihui/knitr/raw/master/inst/examples/knitr-minimal_knit_.md)
  - output: [knitr-minimal.md](https://github.com/yihui/knitr/blob/master/inst/examples/knitr-minimal.md) (GitHub does the job of parsing the md file to HTML)
- HTML
  - html source: [knitr-minimal\_knit\_.html](https://github.com/yihui/knitr/blob/master/inst/examples/knitr-minimal_knit_.html)
  - output: [knitr-minimal.html](https://github.com/downloads/yihui/knitr/knitr-minimal.html)

Except the GFM demo, you can directly use `knit()` to knit the input file, e.g.,

{% highlight r %}
library(knitr)
knit('knitr-minimal.Rnw')
knit('knitr-minimal_knit_.html')
{% endhighlight %}
{'fraction_non_alphanumeric': 0.14433811802232854, 'fraction_numerical': 0.0, 'mean_word_length': 4.407327586206897, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1048651', 'n_tokens_mistral': 951, 'n_tokens_neox': 920, 'n_words': 197}