在 R Notebook 输出中包含绘图代码

问题描述

这感觉应该很简单,但我不知道如何在 R Notebook 中包含用于创建绘图的代码(即在它创建的绘图上方)。令人困惑的是,一些在线示例(例如下面的示例,来自 here)显示的情节代码自动包含在 html_notebook 输出中,但其他来源(例如底部图像,来自 here显示隐藏的情节代码(这是我目前得到的行为)。我知道底部示例是 html_document 输出而不是 html_notebook 并且之间存在差异两者,但无论如何我使用的是 html_notebook 但看到第二张图片中的行为。

我尝试了 herehere 列出的不同块选项(例如 echo=TRUE),但无济于事,因此将不胜感激。

example showing what I want

example showing what I get at the moment

解决方法

第一个文档使用 lct <- Sys.getlocale("LC_TIME") Sys.setlocale("LC_TIME","C") Sys.setlocale("LC_TIME",lct) Sys.getlocale(category = "LC_ALL") Sys.setlocale("LC_TIME","English") YAML 选项和 chunck 选项 code_folding: show

echo = T

enter image description here

第二个文档只使用全局块选项--- title: "Notebook" output: html_notebook: code_folding: show html_document: code_folding: show ---

echo = F

enter image description here

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...