我测试运行我的闪亮应用程序,它工作。但是,当我将它上传到shinyapp.io并运行它时,它会给我一个错误

时间:2015-07-29 19:50:32

标签: r shiny

我在shinyapp.io服务器上运行了我的闪亮应用,它给了我这个错误:

“错误:'闭包'类型的对象不是子集”

我有以下server.R和UI.R文件:

SERVER.R

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

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

shinyServer(function(input, output){

selected_data <- reactive({

minyear <- input$year[1]
maxyear <- input$year[2]

velo <- data %>% group_by(pitcher_name, pitch_type, Year) %>% summarise(velocity = mean(start_speed)) %>%
  arrange(velocity) %>% filter(pitcher_name %in% input$pitcher_name) %>% arrange(pitcher_name) %>% filter(Year >= minyear) %>% filter(Year <= maxyear) %>% filter(pitch_type %in% input$pitch_type)
print(velo)
 })

output$pitcher_bar <- renderPlot({

p <- ggplot(data=selected_data(), aes(x = Year, y = velocity, group = pitch_type, color = pitch_type)) + geom_line() + geom_point(size=3, fill="white") + xlab("Year") + ylab("Velocity") + ggtitle("Velocity") + theme_bw()
print(p)
})


})

UI.R

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

shinyUI(fluidPage(

titlePanel("Velocity Attribute"),

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

)))

我怀疑需要进行的调整与数据变量有关吗?

0 个答案:

没有答案