这是我的Rmarkdown代码:
---
title: "Tutorial"
output:learnr::tutorial:
code_folding: hide
runtime: shiny_prerendered
---
```{r setup}图书馆(Learnr)
Knitr::opts_chunk$set(回声=假)
## Topic 1
### Exercise
*Here's a simple exercise with an empty code chunk provided for entering the answer.*
Write the R code required to add two plus two:
```{r two-plus-two, exercise=TRUE}图书馆(Tidyverse)
%>%选择(cyl,mpg)
### Exercise with Code
*Here's an exercise with some prepopulated code as well as `exercise.lines = 5` to provide a bit more initial room to work.*
Now write a function that adds any two numbers and then call it:
```{r add-function, exercise=TRUE, exercise.lines = 5}添加<- function() {
}
我已经试过了所有的选择,但都没有用。有什么帮助吗?
发布于 2022-01-07 13:49:26
看起来,code-folding选项不适用于output "learnr"。
为了html_doc -是的。F.e.:
output:
html_document:
code_folding: hide但是您可以使用details尝试下一个解决方案。
CSS:
<style>
details {
border: 1px solid;
border-radius: 10px;
padding: .1em .5em 0;
text-align: right;
}
</style>使用:
<details>
<summary>Show/hide code</summary>
```{r two-plus-two, exercise=TRUE}图书馆(Tidyverse)
%>%选择(cyl,mpg)
</details>输出:

P.S.如果您需要对IE/Edge的支持,请看there
https://stackoverflow.com/questions/70614465
复制相似问题