RMarkdown 文件中的 R 程式碼

在 Tidyverse 中以資料溝通

Timo Grossenbacher

Data Journalist

在 Tidyverse 中以資料溝通

加入 R 區塊


```{r}
x <- 2 + 2
x


> 4

2 plus 2 equals r 2 + 2.

` 2 plus 2 equals 4.

在 Tidyverse 中以資料溝通

`knitr` 套件

1 R for Data Science (http://r4ds.had.co.nz/r-markdown.html)
在 Tidyverse 中以資料溝通

R 區塊選項


```{r include=FALSE}
x <- 2 + 2
x

> 


x

----CODE_GLUE---- `

4

在 Tidyverse 中以資料溝通

更多 R 區塊選項

選項 作用
include 是否顯示 R 程式碼區塊與其輸出。
echo 是否顯示 R 程式碼區塊。
message 是否顯示訊息輸出。
warning 是否顯示警告輸出。
eval 是否實際執行 R 程式碼區塊。

更多選項請見 knitr 套件的說明頁面

在 Tidyverse 中以資料溝通

一起來練習吧!

在 Tidyverse 中以資料溝通

Preparing Video For Download...