【发布时间】:2015-12-18 08:28:20
【问题描述】:
我很好奇为什么以下方法不起作用。尝试使用对操作按钮的反应进行绘图时,无法在 Shiny 中显示绘图。
知道我做错了什么吗?我已经尝试了很多迭代和方法。如果 Shiny 在响应式环境中调用时可以生成绘图,有什么想法吗?
---
title: "Will not plot"
output: html_document
runtime: shiny
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r, echo = FALSE}
inputPanel(
actionButton("Plot", "Save and Open TRI"),
numericInput("Size", label = "Size", value = 1000, 1000, 5000, 1000)
)
# Works:
renderPlot({
plot(runif(1000)
)})
# Doesn't work:
eventReactive(input$Plot,
{
renderPlot({
plot(runif(1000)
)})
}
)
observeEvent(input$Plot,
{
renderPlot({
plot(runif(1000)
)})
}
)
```
【问题讨论】: