【发布时间】:2018-08-15 09:30:25
【问题描述】:
服务器代码:
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)
数据过滤本身运行良好,但是它没有正确地通过输入?它必须围绕我们如何构建反应函数。它与使用多个选项卡有什么关系吗?谢谢。
【问题讨论】:
-
请提供一个可重现的例子。见stackoverflow.com/questions/48343080/…
标签: shiny shiny-server reactive