object "input" not found. r shiny app

时间:2015-07-28 23:11:08

标签: r shiny

I have server.R and ui.R script below. It keeps me giving me "Object 'input' not found" message and I have no idea why. I made sure that selectInput is named right and such, but no solution.

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()

)


})

Then here is 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"))

 )))

1 个答案:

答案 0 :(得分:4)

It looks the the problem is in group_by where you want the standard evaluation version, group_by_.

Try

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