如何在不运行Rmarkdown中上面的代码的情况下在教程中进行练习?

时间:2019-01-29 07:48:12

标签: r shiny r-markdown

我正在尝试使用有光泽的应用程序在Rmarkdown中编写一个教程。除非我在页面上添加了练习,否则效果很好。当我单击“运行代码”按钮时,它将运行上面的所有代码并执行其实际结果,而不是如屏幕快照中的显示。而且,每当我浏览教程时,都会显示出我在练习中编写的最后一个代码。

有人有这个问题或解决方案吗?

https://www.flickr.com/photos/149687914@N08/46862084412/in/dateposted-public/

https://www.flickr.com/photos/149687914@N08/31973148497/in/dateposted-public/

运动块下面的块是正常的,如下所示: https://www.flickr.com/photos/149687914@N08/31973612587/in/dateposted-public/

当我单击“运行代码”时,它实际上运行了页面上方的所有代码。

完整代码:https://codeshare.io/Gkx8Wx

1 个答案:

答案 0 :(得分:0)

这是我从下面的代码中学到的。这似乎可以正确渲染,请您检查一次?

---
title: "Hello, Tutorial!"
output: learnr::tutorial
runtime: shiny_prerendered
---

```{r}
library(rebmix)
library(learnr)
data("wine", package = "rebmix")
library(data.table)
wine <- as.data.table(wine)
str(wine)
```

### Exercise: Try for the wine Data

Subset rows where Cultivar value is 1, and then subset rows where Cultivar is 1
and Proline is greater than 1000. Then, subset the rows between 10 and 30.

```{r datatable, exercise=TRUE, exercise.eval=FALSE}

```


```{r datatable-solution}

wine1 <- wine[Cultivar == 1 & Proline > 1000]
wine2 <- wine[10:30]

```

```{r datatable-hint-1}

wine1 <- wine[Cultivar == 1, ...]

```
```{r datatable-hint-2}

wine1 <- wine[Cultivar == 1 & Proline > 1000]

```
```{r datatable-hint-3}

wine2 <- wine[10:?]

```

这是屏幕截图

enter image description here