-
Book Overview & Buying
-
Table Of Contents
R for Data Science Cookbook (n)
By :
In an R Markdown report, one can embed R code chunks into the report with the knitr syntax. In this recipe, we introduce how to create and control the output with different code chunk configurations.
Ensure you have installed the latest version of R and RStudio on your operating system. Also, you need to have created and opened a new R Markdown (.rmd) file in RStudio.
Please perform the following steps to create an R code chunk in the markdown report:
First, create a basic code chunk with the knitr syntax:
|
Markdown |
Preview |
|---|---|
|
|
![]() |
We can hide the script by setting echo=FALSE:
|
Markdown |
Preview |
|---|---|
|
|
![]() |
Alternatively, we can stop evaluating the code by setting eval=FALSE:
|
Markdown |
Preview |
|---|---|
|
|
![]() |
Moreover, we can choose not to render both evaluation result and script by setting include...
Change the font size
Change margin width
Change background colour


