|
3 | 3 | [](https://travis-ci.org/rstudio/rmarkdown) |
4 | 4 | [](https://cran.r-project.org/package=rmarkdown) |
5 | 5 |
|
6 | | -The **rmarkdown** package is a next generation implementation of R Markdown based on [Pandoc](http://johnmacfarlane.net/Pandoc/). This implementation brings many enhancements to R Markdown, including: |
| 6 | +The **rmarkdown** package helps you create dynamic analysis documents that combine code, rendered output (such as figures), and prose. You bring your data, code, and ideas, and R Markdown renders your content into a polished document that can be used to: |
7 | 7 |
|
8 | | -- Create HTML, PDF, and MS Word documents as well as [Beamer](https://bitbucket.org/rivanvx/beamer/wiki/Home), [ioslides](https://code.google.com/p/io-2012-slides/), and [Slidy](http://www.w3.org/Talks/Tools/Slidy2/) presentations. |
9 | | -- New markdown syntax including expanded support for tables, definition lists, and bibliographies. |
10 | | -- Hooks for customizing HTML and PDF output (include CSS, headers, and footers). |
11 | | -- Include raw LaTeX within markdown for advanced customization of PDF output. |
12 | | -- Compile HTML, PDF, or MS Word notebooks from R scripts. |
13 | | -- Extensibility: easily define new formats for custom publishing requirements. |
14 | | -- Create interactive R Markdown documents using Shiny. |
| 8 | +<img src="https://bookdown.org/yihui/rmarkdown/images/hex-rmarkdown.png" alt="The rmarkddown hex sticker" width="200" style="padding: 0 15px; float: right;"/> |
15 | 9 |
|
16 | | -Note that PDF output (including Beamer slides) requires an installation of TeX. |
| 10 | +- Do data science interactively within the RStudio IDE, |
17 | 11 |
|
18 | | -See the [R Markdown documentation](https://rmarkdown.rstudio.com) for full details. |
| 12 | +- Reproduce your analyses, |
19 | 13 |
|
20 | | -### Installation |
| 14 | +- Collaborate and share code with others, and |
21 | 15 |
|
22 | | -If you are working within RStudio then you can simply install the [current release](http://www.rstudio.com/ide/download/preview) of RStudio (both the rmarkdown package and Pandoc are included). |
| 16 | +- Communicate your results with others. |
23 | 17 |
|
24 | | -If you want to use the rmarkdown package outside of RStudio then you can install the package from CRAN as follows: |
| 18 | +R Markdown documents can be rendered to many output formats including HTML documents, PDFs, Word files, slideshows, and more, allowing you to focus on the content while R Markdown takes care of your presentation. |
25 | 19 |
|
26 | | -```r |
27 | | -install.packages("rmarkdown") |
28 | | -# or install the dev version via remotes::install_github('rstudio/rmarkdown') |
29 | | -``` |
30 | 20 |
|
31 | | -A recent version of Pandoc (>= 1.12.3) is also required. See the [Pandoc installation instructions](Pandoc.md) for details on installing Pandoc for your platform. |
| 21 | +### Installation |
32 | 22 |
|
33 | | -### Usage |
| 23 | +The easiest way to install the **rmarkdown** package is from within the [RStudio IDE](http://www.rstudio.com/ide/download/preview), but you don't need to explicitly install it or load it, as RStudio automatically does both when needed. A recent version of Pandoc (>= 1.12.3) is also required; RStudio also automatically includes this too so you do not need to download Pandoc if you plan to use rmarkdown from the RStudio IDE. |
34 | 24 |
|
35 | | -The `render` function is used to convert R Markdown (Rmd) files into various output formats (the default is HTML). Calling `render` will knit the specified input document and then produce the final output document using Pandoc: |
| 25 | +If you want to use the rmarkdown package outside of RStudio, you can install the package from CRAN as follows: |
36 | 26 |
|
37 | 27 | ```r |
38 | | -render("input.Rmd") |
39 | | -``` |
40 | | - |
41 | | -You can also specify a plain markdown file in which case knitting will be bypassed: |
42 | | - |
43 | | -```r |
44 | | -render("input.md") |
45 | | -``` |
46 | | - |
47 | | -#### Output Formats |
48 | | - |
49 | | -R Markdown documents can contain a metadata section that includes both title, author, and date information as well as options for customizing output. For example, this metadata included at the top of an Rmd file adds a table of contents and chooses a different HTML theme: |
50 | | - |
51 | | -```yaml |
52 | | ---- |
53 | | -title: "Sample Document" |
54 | | -output: |
55 | | - html_document: |
56 | | - toc: true |
57 | | - theme: united |
58 | | ---- |
59 | | -``` |
60 | | - |
61 | | -R Markdown has built in support for several output formats (HTML, PDF, and MS Word documents as well as Beamer presentations). These formats can also be specified in metadata, for example: |
62 | | - |
63 | | -```yaml |
64 | | ---- |
65 | | -title: "Sample Document" |
66 | | -output: |
67 | | - pdf_document: |
68 | | - toc: true |
69 | | - highlight: zenburn |
70 | | ---- |
71 | | -``` |
72 | | - |
73 | | -If you aren't specifying format options you can also just use a simple format name: |
74 | | - |
75 | | -```yaml |
76 | | ---- |
77 | | -title: "Sample Document" |
78 | | -output: pdf_document |
79 | | ---- |
80 | | -``` |
81 | | - |
82 | | -Multiple formats can be specified in metadata: |
83 | | - |
84 | | -```yaml |
85 | | ---- |
86 | | -title: "Sample Document" |
87 | | -output: |
88 | | - html_document: |
89 | | - toc: true |
90 | | - theme: united |
91 | | - pdf_document: |
92 | | - toc: true |
93 | | - highlight: zenburn |
94 | | ---- |
| 28 | +install.packages("rmarkdown") |
95 | 29 | ``` |
96 | 30 |
|
97 | | -To select from the various formats defined you can pass a format name to `render`. For example: |
| 31 | +If you want to use the development version of the rmarkdown package (either with or without RStudio), you can install the package from GitHub via the [**remotes** package](https://remotes.r-lib.org): |
98 | 32 |
|
99 | 33 | ```r |
100 | | -render("input.Rmd", "pdf_document") |
| 34 | +remotes::install_github('rstudio/rmarkdown') |
101 | 35 | ``` |
102 | 36 |
|
103 | | -If no explicit format name is passed to `render` then the first one defined will be used. You can also render all formats defined in the file with: |
| 37 | +If not using the RStudio IDE, you'll need to install a recent version of Pandoc (>= 1.12.3); see the [Pandoc installation instructions](https://rmarkdown.rstudio.com/docs/articles/pandoc.html) for help. |
104 | 38 |
|
105 | | -```r |
106 | | -render("input.Rmd", "all") |
107 | | -``` |
| 39 | +### Usage |
108 | 40 |
|
109 | | -#### Shared Output Formats |
| 41 | +The easiest way to make a new R Markdown document is from within RStudio. Go to _File > New File > R Markdown_. From the new file wizard, you may: |
110 | 42 |
|
111 | | -You can also define output formats externally in a file named `_output.yml` located in the same directory as the R Markdown source file. For example: |
| 43 | ++ Provide a document title (_optional but recommended_), |
| 44 | ++ Provide an author name (_optional but recommended_), |
| 45 | ++ Select a default output format- HTML is the recommended format for authoring, and you can switch the output format anytime (_required_), |
| 46 | ++ Click **OK** (_required_). |
112 | 47 |
|
113 | | -```yaml |
114 | | -html_document: |
115 | | - toc: true |
116 | | - theme: united |
117 | | -pdf_document: |
118 | | - toc: true |
119 | | - highlight: zenburn |
120 | | -``` |
| 48 | +Once inside your new `.Rmd` file, you should see some boilerplate text that includes code chunks. Use the "Knit" button in the RStudio IDE to render the file and preview the output with a single click or use the keyboard shortcut Cmd/Ctrl + Shift + K. |
121 | 49 |
|
122 | | -Using an `_output.yml` file is a good way to share output settings across multiple R Markdown files in the same directory. |
| 50 | +You can also delete all the text below the YAML frontmatter and fill in your own `.Rmd` by: |
123 | 51 |
|
124 | | -#### Output Format Functions |
| 52 | ++ Adding code chunks (keyboard shortcut: `Ctrl + Alt + I`; OS X: `Cmd + Option + I`), |
| 53 | ++ Writing prose with [Markdown formatting](https://www.markdowntutorial.com/), and |
| 54 | ++ Running each code chunk interactively by clicking the  icon within RStudio. |
125 | 55 |
|
126 | | -Output formats need not be specified in metadata. In fact, metadata is just a convenient way to invoke functions that implement output formats. There are seven built-in output formats each exported as a function from the package: |
| 56 | +You can also click "Knit to HTML" again to render the full document with all code chunks. For more help getting started in R Markdown, please see the [R Markdown website](https://rmarkdown.rstudio.com/lesson-1.html) or use the **"Get Started"** links at the top of this page. |
127 | 57 |
|
128 | | -- `html_document` |
129 | | -- `pdf_document` |
130 | | -- `word_document` |
131 | | -- `md_document` |
132 | | -- `beamer_presentation` |
133 | | -- `ioslides_presentation` |
134 | | -- `slidy_presentation` |
| 58 | +### Getting help |
135 | 59 |
|
136 | | -As you'd expect, these functions can also be invoked as part of the call to `render`, for example: |
137 | | - |
138 | | -```r |
139 | | -render("input.Rmd", html_document(toc = TRUE)) |
140 | | -render("input.Rmd", pdf_document(latex_engine = "lualatex")) |
141 | | -render("input.Rmd", beamer_presentation(incremental = TRUE)) |
142 | | -``` |
| 60 | +There are two main places to get help: |
143 | 61 |
|
144 | | -For more details on the options available for each format see their respective help topics. |
| 62 | +1. The [RStudio community](https://community.rstudio.com/c/R-Markdown) is a friendly place to ask any questions about rmarkdown and the R Markdown family of packages. |
145 | 63 |
|
146 | | -### License |
| 64 | +1. [Stack Overflow](https://stackoverflow.com/questions/tagged/r-markdown) is a great source of answers to common rmarkdown questions. It is also a great place to get help, once you have created a reproducible example that illustrates your problem. |
147 | 65 |
|
148 | | -The **rmarkdown** package is licensed under the GPLv3 (<http://www.gnu.org/licenses/gpl.html>). |
0 commit comments