echo=
The echo=
chunk option governs the rendering of the R
code inside a chunk. By default, it is set to TRUE
(or T
). If it is TRUE
, the code inside of the chunk gets printed – or echoed – in the knitted document. For instance, the code in the following chunk will appear:
my_data <- tibble(
score = rnorm(n = 1000,
mean = 100,
sd = 15))
echo=FALSE
hides the code but produces the output
eval=
The eval=
chunk option governs the evaluation of the R
code inside a chunk. By default, it is set to TRUE
(or T
). If it is set to FALSE
, the code will appear but will not get run and so any code dependent on objects in this code chunk will fail.
my_data2 <- tibble(
score = rnorm(n = 1000,
mean = 100,
sd = 15))
Now there is not my_data2
object and so the plot cannot be generated
my_data2 %>%
ggplot(aes(x = score)) +
geom_histogram(fill = "#ff450088", colour = "black") +
theme_classic()
## Error in eval(lhs, parent, parent): object 'my_data2' not found
include=
The include=
chunk option cahnges whether or not both code and output should be included. By default, it is set to TRUE
(or T
). If it is TRUE
, both code and output (plots, tables, etc) will be printed in the knitted document. For instance, here, both code chunks and the plot appear:
my_data <- tibble(
score = rnorm(n = 1000,
mean = 100,
sd = 15))
But when eval=
is set to FALSE
none of it will be there.