R has markdown functionality (similar to IPython) packages which helps us to create web reports and dynamic web content. Lets go through a quick tutorial about creating a R Markdown.
Make sure you have latest version of R Studio and following two packages installed:
- knitr
- markdown
This will create a markdown file. It should look like,
Lets save the file with some name. We can see the file extension as rmd (R MarkDown). Now before we edit the content, lets explore few concepts.
We can divide all the content from this file into two categories,
- Content which is enclosed in ```{r} and ```. Lets call it R-text
- Remaining content (which is not code), lets call it plain-text.
Note: We can display values of R variables into plain-text, using 'r Var'.
For plain-text,
- The content above "=====" is considered as Title (or Header 1).
- We can write secondary title (Header 2) after "=====" and before "----"
- Similarly ### Header 3 and #### Header 4
- For italic we can use *text* or _text_
- You can browse similar functions through option "MD" or "Markdown quick reference" on top-left.
- We can use option eval = TRUE in ```{r} option which evaluates the code inside.
- If we set eval =FALSE then we can see the code block but it wont be executed.
- The default configuration is eval = TRUE
- We can decide the dimensions like ```{r fig.width=8, fig.height=6}
Lets plot a graph using,
> plot(Mileage~Price,data=cars)
No comments:
Post a Comment