Shiny 反应性未显示具有工作数据筛选的适当图形
服务器代码:Shiny 反应性未显示具有工作数据筛选的适当图形,shiny,shiny-server,reactive,Shiny,Shiny Server,Reactive,服务器代码: silver_state <- fread("./Data/silver_state.csv") silver <- silver_state %>% arrange(total_drug_cost) state_cast <- reactive({ if(input$sort == "alphabetical"){ silver <- silver } else if(input$sort == "descending"){ silve
silver_state <- fread("./Data/silver_state.csv")
silver <- silver_state %>% arrange(total_drug_cost)
state_cast <- reactive({
if(input$sort == "alphabetical"){
silver <- silver
}
else if(input$sort == "descending"){
silver <- silver_state %>% arrange(desc(total_drug_cost))
silver$nppes_provider_state <- factor(silver$nppes_provider_state,
levels = silver$nppes_provider_state[order(silver$total_drug_cost)])
}
else{
silver <- silver_state %>% arrange(total_drug_cost)
silver$nppes_provider_state <- factor(silver$nppes_provider_state,
levels = silver$nppes_provider_state[order(silver$total_drug_cost)])
}
})
output$compare <- renderPlot({
ggplot(silver) +
geom_bar(aes(x = nppes_provider_state, y = total_drug_cost), position
= position_stack(reverse = TRUE), stat = "identity") +
coord_flip() +
labs(title = "Total Cost of Drugs per State", y = "Total Drug Cost",
x = "State")
})
}
shinyServer(my.server)
数据过滤本身运行良好,但是,它没有正确地通过输入?它必须是围绕着我们如何构造反应函数的东西。这可能与使用多个选项卡有关吗?谢谢。state\u cast没有在任何地方使用,也不应该存在。它看起来像是被滥用的副作用唯一的功能。只需将其内容移动到renderPlot即可
此外,您有一个银色的,请提供一个可复制的例子。看见