错误:结果的长度必须为26316,而不是0

时间:2019-04-04 09:29:31

标签: shiny shiny-reactivity

当我在Rstudio中运行以下代码时,在主面板中出现错误。 结果的长度必须为26316,而不是0

我试图对过滤器功能进行一些更改,但仍然出现错误

library(shiny)
library(ggplot2)
library(dplyr)
library(ggplot2)
data<-read.csv("Week_11vs12.csv",stringsAsFactors = FALSE)
ui<-fluidPage(
  titlePanel("Weekly Report for week 12"),
  sidebarLayout(
    sidebarPanel(
      selectInput("WeekInput", "Select Period",choices = sort(unique(data$Week),decreasing = FALSE)),
      selectInput("regionsInput", "Select Market",
                  choices = unique(data$Regions)),
      radioButtons("genreInput", "Genre type",
                               choices = unique(data$Genre),selected = "ANY TV")
    ),
    mainPanel(textOutput("results"),
              br(),
              plotOutput("coolplot"))
  )
)
library(shiny)
server <- function(input, output) {
  filtered <- reactive({
    group_by(data)%>%
      filter(Week >= input$weekInput[1],
             Week <= input$weekInput[2],
             Genre == input$genreInput,
             Regions == input$regionsInput
      )
  })

  output$coolplot <- renderPlot({
    ggplot(filtered(), aes(Universe)) +
      geom_histogram()
  })

  output$results <- renderTable({
    filtered()
  })
}

0 个答案:

没有答案