r-markdown - 在 RStudio 的 R Markdown 中,四个反引号块之后的代码块失去交互性(例如,“运行当前块”按钮消失)
问题描述
我按照 Xie Yihui 的提示R Markdown
在文档的输出中逐字呈现代码块。虽然结果看起来不错,但我注意到 RStudio 界面上的格式和交互性发生了变化,也就是说,四个反引号块之后的代码块不再显示为右上角的“运行当前块”等按钮。在下面R Markdown
插入。
如何在保持界面交互性的同时继续使用四反引号技巧(或使用具有相同效果的其他技巧)?
---
title: "Diamond sizes"
date: '2016-08-25'
output:
pdf_document: default
word_document: default
html_document: default
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(ggplot2)
library(dplyr)
```
To show a verbatim R code chunk following Xie Yihui's trick ([link](https://yihui.org/en/2017/11/knitr-verbatim-code-chunk/)):
````
`r ''````{r}
library(gapminder)
gapminder %>% ggplot(aes(year, lifeExp, group = country)) +
geom_line(alpha = 1/3)
```
````
```{r}
library(gapminder)
gapminder %>% ggplot(aes(year, lifeExp, group = country)) +
geom_line(alpha = 1/3)
```
解决方案
您需要在最后添加最后一个三次反引号。我确实看到了,但是它确实在渲染的文档中添加了 3 个额外的标记,但这就是我所做的,你至少得到了另一个块标记
更新代码 2021 年 8 月 21 日
---
title: "Untitled"
author: "Daniel"
date: "8/21/2021"
output: html_document
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(ggplot2)
library(dplyr)
```
To show a verbatim R code chunk following Xie Yihui's trick ([link](https://yihui.org/en/2017/11/knitr-verbatim-code-chunk/)):
````
`r ''````{r}
library(gapminder)
gapminder %>% ggplot(aes(year, lifeExp, group = country)) +
geom_line(alpha = 1/3)
```
````
```{r}
library(gapminder)
gapminder %>% ggplot(aes(year, lifeExp, group = country)) +
geom_line(alpha = 1/3)
```
推荐阅读
- networking - 如何关闭 wget 代理?
- loops - 如何在每组 25 次迭代后暂停 5 分钟直到完成的循环?
- r - FE 回归产生长向量 - R.3.5.0
- python - 带有pyspark的火花图功能
- javascript - JavaScript - Does the placement/order of spread operator in an object matter?
- javascript - 将参数从父函数传递给子函数,javascript
- c# - 具有可绑定属性的 Xamarin 表单 ValueConverter
- anova - 实验的定性设计 - 3 个因素 3 个水平 - 分类响应变量
- css - Google 字体 Raleway Dots 仅在 chrome 上显示 Raleway
- python - 数据字典优化代码(python函数提示)