用于教学Shiny的学习包...可以吗?

时间:2019-02-04 19:42:04

标签: r shiny r-markdown

我很喜欢使用R的学习者和评分者软件包。我设法结合了一些闪亮的元素,非常好!

但是,我想参加一些练习,学习者可以针对闪亮的问题写,检查和提交答案。但是,练习中的运行代码功能没有任何作用(我得到一个闪亮的窗口,说静态R Markdown文档中不支持Shiny应用程序),所以我假设它不起作用或我错过了什么?

这是练习代码的示例;

---
title: "Programming basics"
output:
  learnr::tutorial:
    progressive: true
    allow_skip: true
runtime: shiny_prerendered
---

```{r ex_shiny_1, exercise=TRUE}
library(shiny)
ui <- fluidPage(
  titlePanel("My First App"),
  sidebarLayout(
    sidebarPanel("inputs will go here"),
    mainPanel("outputs will go here")
  )
)

server <- function(input, output) {}

shinyApp(ui = ui, server = server)
```

我知道我可以在学习器中使用测验,但是我真的希望用户能够看到他们闪亮的代码运行,而不必从教程转到RStudio IDE。

我已经使用类似的方法设法在教程中包含了闪亮的元素,并且效果很好;

sliderInput("bins", "Number of bins:", 30, min = 1, max = 50)
plotOutput("distPlot")
output$distPlot = renderPlot({
  x = faithful[, 2]  # Old Faithful Geyser data
  bins = seq(min(x), max(x), length.out = input$bins + 1)
  hist(x, breaks = bins, col = 'darkgray', border = 'white')
})

谢谢!

0 个答案:

没有答案
相关问题