R Markdown enables you to generate reproducible and dynamic reports straight from your R code, documenting your works as an HTML, PDF, Word, slideshows, and more.
We will use knitr
and rmarkdown
packages to write R Markdown files in Rstudio and generate report in various formats.
Let’s create a report on analysis of ‘basic salary’ data.
#Install R Packages
install.packages("knitr")
install.packages("rmarkdown")
In the menu bar of RStudio, click File -> New File -> R Markdown.
You will see an untitled .Rmd file. Save the file File -> Save As…
Few of the output formats available to use with R Markdown are as follows:
Arguments can be added to each code chunk, which allow you to customize how or if you want code to be processed or appear on the rendered output (pdf document, html document, etc).
Here we have specified echo=TRUE
to display the code along with the results.
Comments can be added using ‘#’ followed by the text.
R Code Chunk Arguments: