簡體   English   中英

在 R 筆記本 output 中包含繪圖代碼

[英]Include code for plots in an R Notebook output

這感覺應該很簡單,但我不知道如何在 R 筆記本中包含用於創建 plot 的代碼(即在它創建的 Z32FA6E1B78A9D4028953E60564A2AA4 之上)。 Confusingly, some online examples (eg the one immediately below, from here ) show the plot code being included automatically in the html_notebook output, but other sources (eg the bottom image, from here show the code for the plot being hidden (which is the我現在得到的行為)。我知道底部示例是html_document output 而不是html_notebook並且兩者之間存在差異,但無論如何我使用的是html_notebook但看到第二張圖片中的行為.

我嘗試了此處此處列出的不同塊選項(例如echo=TRUE ),但無濟於事,因此將不勝感激。

顯示我想要的示例

顯示我目前得到的示例

第一個文檔使用code_folding: show YAML option with chunck option echo = T

---
title: "Notebook"
output:
  html_notebook:
    code_folding: show
  html_document:
    code_folding: show
---

在此處輸入圖像描述

第二個文檔僅使用全局塊選項echo = F

---
title: "Notebook"
output:
  html_document
---

`r knitr::opts_chunk$set(echo = F)`

```{r}
plot(1)
```

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM