R Markdown v0.9.5
This article is originally published at https://www.rstudio.com/blog/
A new release of the rmarkdown package is now available on CRAN. This release features some long-requested enhancements to the HTML document format, including:
The ability to have a floating (i.e. always visible) table of contents.
Folding and unfolding for R code (to easily show and hide code for either an entire document or for individual chunks).
Support for presenting content within tabbed sections (e.g. several plots could each have their own tab).
Five new themes including “lumen”, “paper”, “sandstone”, “simplex”, & “yeti”.
There are also three new formats for creating GitHub, OpenDocument, and RTF documents as well as a number of smaller enhancements and bug fixes (see the package NEWS for all of the details).
Floating TOC
You can specify the toc_float
option to float the table of contents to the left of the main document content. The floating table of contents will always be visible even when the document is scrolled. For example:
---
title: "Habits"
output:
html_document:
toc: true
toc_float: true
---
Here’s what the floating table of contents looks like on one of the R Markdown website’s pages:
Code Folding
When the knitr chunk option echo = TRUE
is specified (the default behavior) the R source code within chunks is included within the rendered document. In some cases it may be appropriate to exclude code entirely (echo = FALSE
) but in other cases you might want the code available but not visible by default.
The code_folding: hide
option enables you to include R code but have it hidden by default. Users can then choose to show hidden R code chunks either indvidually or document wide. For example:
---
title: "Habits"
output:
html_document:
code_folding: hide
---
Here’s the default HTML document template with code folding enabled. Note that each chunk has it’s own toggle for showing or hiding code and there is also a global menu for operating on all chunks at once.
Note that you can specify code_folding: show
to still show all R code by default but then allow users to hide the code if they wish.
Tabbed Sections
You can organize content using tabs by applying the .tabset
class attribute to headers within a document. This will cause all sub-headers of the header with the .tabset
attribute to appear within tabs rather than as standalone sections. For example:
## Sales Report {.tabset}
### By Product
(tab content)
### By Region
(tab content)
Here’s what tabbed sections look like within a rendered document:
Authoring Enhancements
We also shouldn’t fail to mention that the most recent release of RStudio included several enhancements to R Markdown document editing. There’s now an optional outline view that enables quick navigation across larger documents:
We also also added inline UI to code chunks for running individual chunks, running all previous chunks, and specifying various commonly used knit options:
What’s Next
We’ve got lots of additional work planned for R Markdown including new document formats, additional authoring enhancements in RStudio, and some new tools to make it easier to publish and manage documents created with R Markdown. More details to follow soon!
Thanks for visiting r-craft.org
This article is originally published at https://www.rstudio.com/blog/
Please visit source website for post related comments.