未找到对象 "input"。闪亮的应用程序

object "input" not found. r shiny app

下面有 server.R 和 ui.R 脚本。它让我一直给我 "Object 'input' not found" 消息,我不知道为什么。我确保 selectInput 的命名正确等等,但没有解决方案。

SERVER.R

library(shiny)
library(data.table)
library(dplyr)
library(ggplot2)

shinyServer(function(input, output){



selected_data <- reactive({

data <- data.table::fread(input="final_master_table.csv",header = TRUE,     data.table = TRUE)
data <- data[,V1:=NULL]

 velo <- data %>% group_by(input$pitcher_name, input$pitch_type, input$year) %>% summarise(velocity = mean(data$start_speed)) %>%
  arrange(velocity)

data2 <- filter(velo,input$pitcher_name)
data2 <- data2[data2$Year %in% input$year,]
return(data2)
})

output$pitcher_bar <- renderPlot(

ggplot(selected_data(), aes(x = input$year, y = selected_data()$velocity, group = input$pitch_type, color = input$pitch_type)) + 
  geom_line(aes(linetype=input$pitch_type), size=1) + geom_point(size=3, fill="white") + 
  xlab("Year") + ylab("Velocity") + ggtitle("Velocity") + theme_bw()

)


})

那么这里是UI.R:

UI.R

library(shiny)
library(data.table)
library(dplyr)
library(ggplot2)

shinyUI(fluidPage(

titlePanel("Boxplot of MLB Pitcher Attributes"),

sidebarLayout(

sidebarPanel(

# Slider for setting year parameter

sliderInput("year",
            "year:",
            min=2008,max=2015,value=c(2008,2015)
            ),

 selectInput("pitcher_name","Pitcher Name:", choices = unique(data$pitcher_name)),

 selectInput("pitch_type","Pitch Type:", choices = unique(data$pitch_type)),

 helpText("Please wait 30 seconds for 2008 to 2015 pitchFx data to load")

 ),

 mainPanel(plotOutput("pitcher_bar"))

 )))

看起来问题出在 group_by 您想要标准评估版的地方,group_by_

尝试

group_by_(.dots=c(input$pitcher_name, input$pitch_type, input$year))