【发布时间】:2020-12-03 22:28:46
【问题描述】:
使用来自ggplot2 的midwest 数据框:
# (in app_ui.r)
poverty_sidebar <- sidebarPanel(
radioButtons(
inputId = "state",
label = "State",
choices = list("IL" = 1, "IN" = 2, "MI" = 3, "OH" = 4, "WI" = 5),
selected = 1
))
poverty_plot <- mainPanel(
plotOutput(
outputId = "poverty_plot"
)
)
# (in app_server.r)
server <- function(input, output) {
output$poverty_plot <- renderPlot({
filtered <- filter(midwest, state == input$state)
plot <- ggplot(data = filtered) +
geom_col(x = county, y = poppovertyknown)
return(plot)
})
似乎不起作用,给我一个“找不到对象county”错误。是在做filter(midwest, state == input$state) 错误的方法吗?还是错误出在我的单选按钮上?
【问题讨论】:
-
试试
choices = list("IL" , "IN" , "MI" , "OH" , "WI" ) -
给我同样的错误:“找不到对象
county”