繁体   English   中英

找不到对象“输入”。 r闪亮的应用

[英]object “input” not found. r shiny app

我在下面有server.R和ui.R脚本。 它使我不断收到“找不到对象'输入'”消息,我也不知道为什么。 我确保将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))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM