我想通过下拉列表过滤图上的状态。例如,我有密度图和状态列表的下拉列表,当我更改状态图时,应将其更改为开启状态。但是,使用我的代码更改状态后,它什么也没发生。
我的代码:
output$overat <- renderPlot({
filtered <-
Medi_sum_small %>%
filter(State == input$e1)
ggplot(Medi_sum_small, aes(Hospital_Ownership)) +
geom_density(aes(fill=factor(Hospital_overall_rating)), alpha=0.7) +
labs(x="Ownership",
fill="Overall rating") +
scale_x_discrete(labels = function(x) str_wrap(x,width=0.3))
})
box(
title = "Select State"
,width = 3
,solidHeader = TRUE
,status = "primary"
,selectInput(
'e1', 'State',
c("All",unique(Medi_sum_small$State))
)
Graphs should be changed when I change the stage.
答案 0 :(得分:0)
在我的评论之后,尝试一下-
ggplot(filtered, aes(Hospital_Ownership)) +
geom_density(aes(fill=factor(Hospital_overall_rating)), alpha=0.7) +
labs(x="Ownership",
fill="Overall rating") +
scale_x_discrete(labels = function(x) str_wrap(x,width=0.3))
答案 1 :(得分:0)
现在我可以了,我将代码更改为:
logreturn
非常感谢您