r - 使用 Shiny 和 FlexDashboard 运行饼图时出现问题
问题描述
我是 Stack Overflow 的新手,我也是 R 的初学者,但我正在努力改进。我想知道是否有人可以解决我创建带有区域选项的仪表板的问题。我从https://beta.rstudioconnect.com/jjallaire/shiny-eruptions/举了一个例子,你可以看到一些参考资料。在这次 Covid-19 危机期间,我正在尝试为我的国家意大利创建一个仪表板。提前谢谢
---
title: "Old Faithful Eruptions"
output: flexdashboard::flex_dashboard
runtime: shiny
---
```{r global, include=FALSE}
# load data in 'global' chunk so it can be shared by all users of the dashboard
library(flexdashboard)
library(plotly)
library(covid19italy)
library(ggplot2)
library(dplyr)
library(tidyr)
italy_province2 <- italy_province %>%
mutate(date=as.Date(date, format= "%y/%m/%d"))%>%
group_by(province_code) %>%
arrange(desc(date)) %>%
slice(1)
```
Column {.sidebar}
-----------------------------------------------------------------------
Waiting time between eruptions and the duration of the eruption for the
Old Faithful geyser in Yellowstone National Park, Wyoming, USA.
```{r}
selectInput("region", label = "Region:",
choices = c("Piemonte","Valle d'Aosta","Liguria","Lombardia","P.A. Bolzano",
"P.A. Trento","Veneto","Friuli Venezia
Giulia","Emilia-Romagna","Marche","Toscana","Umbria","Lazio","Campania","Abruzzo","Molise", "Puglia","Basilicata","Calabria","Sicilia","Sardegna" ), selected = "Piemonte")
```
Column
-----------------------------------------------------------------------
### Geyser Eruption Duration
```{r}
renderPlot({
italy_province2 %>%
filter(date == max(date), region_name == toString(input$region) %>%
ggplot(labels = ~province_name, values = ~total_cases,
textinfo="label+percent",
type = 'pie')
})
解决方案
推荐阅读
- javascript - 为什么我的网络应用程序不会将数据发送到我的 google firebase 数据库?
- java - 如何在运行时显示多个图像(换行到下一行)
- macos - 为什么这个访问父目录的代码在 Matlab 中不起作用?
- r - 如何在不删除行中的其余数据的情况下获得相交的行名
- javascript - 如何使函数更改先前分配的变量的值
- python - 如何创建“列表”类的子类,在实例化时对其进行排序?
- unity3d - 在播放模式下省略所有 Debug.Asserts
- ios - 使用verticalAlighment和alignmentGuide对齐视图的底部对齐
- reactjs - 我无法在按钮单击时删除 CRUD 应用程序中的组件
- excel - 需要一个工作表公式来检测单元格中的分隔符是否应该被忽略