r - 无法在 r shiny 中运行流图
问题描述
我是新手shiny
并试图从用户选择的国家/stremgraph
地区制作一个闪亮的情节。selectInput
用户界面
library(shiny)
library(shinydashboard)
library(shinythemes)
library(shinyWidgets)
library(highcharter)
library(streamgraph)
tabPanel("Compare Countries",
# Application title
titlePanel("Select Countries to Compare"),
sidebarLayout(
sidebarPanel(width = 3,
selectInput(inputId = "id_compare_countries",
label = "Select Countries for comparison",
choices = unique(ts_all_long$Country.Region),
selected = c("United Kingdom","India","Spain","US","Russia","Canada","Germany"),
multiple = TRUE)
),
mainPanel(
# h2("~~~~~~~~~~WIP - Under Construction~~~~~~~~~~"),
streamgraphOutput("stream_cases"),
plotlyOutput("stream_cases2", height = "500px", width = "120%")
) # mainpanel end
) # sidebarLaout end
) # tabPanel end
服务器
library(shiny)
library(tidyverse)
library(tidytext)
library(scales)
library(lubridate)
library(glue)
library(ggtext)
library(highcharter)
library(plotly)
library(streamgraph)
library(shinyWidgets)
####################### tab 4 Plots ##############################
compare_daily_stacked_filtered <- reactive({
req(input$id_compare_countries)
compare_daily_stacked_filtered <- daily_stacked_df %>%
arrange(desc(date)) %>%
filter(Country.Region %in% input$id_compare_countries
)
}) %>%
bindCache(input$id_compare_countries)
# Streamgraph
output$stream_cases <- renderStreamgraph({
compare_daily_stacked_filtered() %>%
filter(
Daily_Cases_type %in% c("Confirmed_daily"),
Cases_count > 0,
) %>%
streamgraph(date = "date", value = "Cases_count", key = "Country.Region") %>%
sg_fill_tableau() %>%
sg_title(title = glue("Overal Countries Daily Cases trend Stream as of: {max(daily_stacked_df$date)}"))
})
# Cross check by Area graph in plotly
output$stream_cases2 <- renderPlotly({
ggplotly(ts_all_long %>%
filter(Country.Region %in% input$id_compare_countries
) %>%
ggplot(aes(x = date, y = Confirmed_daily, fill = Country.Region)) +
geom_area(alpha = 0.7) +
scale_fill_tableau() +
theme_transparent() +
theme(panel.grid.major = element_blank(),
panel.background = element_rect(fill = "transparent",colour = NA),
plot.background = element_rect(fill = "transparent",colour = NA),
legend.background = element_rect(fill = "transparent",colour = NA))
)
})
我试图与另一个正在显示但没有显示的区域图进行交叉检查。plotly
streamgraph
解决方案
推荐阅读
- reactjs - 如何限制对我的反应构建静态文件的访问?
- jenkins - 如何使用可选参数执行 groovy 共享库
- python - 无法访问迭代器中的批处理项目 - Torchtext 属性错误:“字段”对象没有属性“词汇”
- css - 简单的网络服务器无法重新获取网页。页面包含 html 和大型 css 文件,例如 stat.st_size=22926
- firebase - 尝试在真实设备中运行颤振应用程序时出错
- azure-ad-b2c - Azure B2C 用户流不显示任何应用程序
- c# - 嵌套线程中断计时器
- azure - Terraform - 从本地状态文件中删除资源
- wordpress - 云耀斑超级缓存插件问题
- java - 具有空值的 JPA / Hibernate 复合主键