1.2 Background
- R Markdown Knitr Hooks
- R Markdown Knitr Options
- R Markdown Knitr Root.dir
- R Markdown Knitr To Pdf Error
Markdown is a language for formatting not-too-complicated documents using just a few text symbols. It is designed to be easy to read and write. If you read and write email, you are probably already familiar with many of these formatting conventions. For more specifics about Markdown see John Gruber's Markdown article.
R Markdown Knitr Hooks
Dynamic Markdown has been implemented for a number of programming languages, including Stata and R. Within Stata there is a dynamic markdown package called stmd
that relies on Stata's dyndoc
command, as well as the user-written package markstat
. Each has it's strengths and weaknesses.
- The first official book authored by the core R Markdown developers that provides a comprehensive and accurate reference to the R Markdown ecosystem.
- R markdown with JavaScript visualization libraries. This is a short tutorial on knitr/markdown and JS visualization libraries googleVis and rCharts.With these packages you can create web pages with interactive visualizations from R.
Internally, the Pandoc output format of the current R Markdown document is stored in knitr::optsknit$get('rmarkdown.pandoc.to'), and the Pandoc input. Take a look at the Markdown basics page, and the more complete Markdown syntax, or just the Markdown cheatsheet. Converting Markdown to html You can skip this section and move on to knitr with R Markdown, but for completeness let me explain how to convert a Markdown document to html. R markdown with JavaScript visualization libraries. This is a short tutorial on knitr/markdown and JS visualization libraries googleVis and rCharts.With these packages you can create web pages with interactive visualizations from R.
The system I will describe here is intended primarily for those of us who are already using R Markdown to write documentation in other languages, and would like to use this for Stata as well.
R Markdown is a dynamic markdown system that extends Markdown by allowing you to include blocks of code in one of several programming languages. The code is evaluated, and both the code and it's results are included in a Markdown document. To read more about the details of R Markdown see RStudio's R Markdown webpages
RStudio uses an R package called knitr
(this could also be called directly from R), which includes the ability to evaluate Stata.
The documentation for knitr
can be found in R's Help, from Yihui Xie's web page, or in the book, R Markdown: The Definitive Guide.
Finally, I use some helper functions in a package called Statamarkdown
. While these are not necessary to write dynamic documents based on Stata, they make life easier.
This is a short tutorial on knitr/markdown and JS visualization libraries googleVis and rCharts. With these packages you can create web pages with interactive visualizations from R. This will require minimal or no knowledge of HTML or JavaScript.
R Markdown Knitr Options
You need to have the following R packages and their dependencies installed:
- knitr
- googleVis
- rCharts (not on CRAN)
The tutorial is organized in four parts. First two parts introduce basics about knitr and markdown. The last parts are about using googleVis and rCharts packages in markdown documents. You can download the .Rmd files and run knit2html() on them, or if you are using RStudio you can click 'knit HTML' button on the upper left corner.
1. R and markdown
markdown_knitr.Rmd shows basics of markdown and knitr integration. These tools will help you create an HTML document using R. The output is here. In addition, R markdown basics are described here.
R Markdown Knitr Root.dir
2. Customizing code output in markdown documents
controlling_knitr.Rmd shows how code chunk output can be controlled by knitr options.The output is here
3. Using Google visualization API in markdown documents
googleVis.Rmd shows how to use googleVis package in a markdown document.You can incorporate plots from Google Visualization API. The output is here
4. Using multiple JS visualization libraries in markdown documents
R Markdown Knitr To Pdf Error
rCharts.Rmd shows how to use rCharts package in a markdown document. Using rCharts, you can incorporate various JS visualizations on your HTML document. The output is here.