【发布时间】:2021-04-16 10:20:49
【问题描述】:
我正在尝试开发我的第一个 R 闪亮应用。我正在尝试让用户可以决定他想看哪一年。
我运行的错误是:
Warning: Error in : Problem with `filter()` input `..1`.
x Input `..1` must be of size 1026 or 1, not size 0.
i Input `..1` is `leto == input$leto`.
184: <Anonymous>
我的服务器代码是:
library(shiny)
library(ggplot2)
function(input, output) {
output$graf_dejavnosti <- renderPlot({
graf_dejavnosti <- ggplot(gospodarskadejavnost %>%
filter(leto == input$leto)) +
aes(x=oznaka, y=placa, fill=spol) +
geom_col(position = "dodge") + guides(fill=guide_legend("Leto")) +
labs(title = "Plače po dejavnosti in spolu") + theme(plot.title = element_text(hjust = 0.5)) +
ylab("Plača") + xlab("Dejavnosti") + coord_flip()
print(graf_dejavnosti)
})
output$legenda <- renderTable(gospodarskadejavnost %>%
select(oznaka, dejavnost) %>% unique())
}
我的用户界面代码是:
library(shiny)
fluidPage(
titlePanel(""),
tabPanel("Graf",
sidebarPanel(
selectInput("Leto", label = "Izberi leto",
choices = unique(gospodarskadejavnost$leto))),
mainPanel(plotOutput("graf_dejavnosti"),
tableOutput("legenda")))
)
感谢您的帮助!
【问题讨论】: