【问题标题】:object "input" not found. r shiny app找不到对象“输入”。 r闪亮的应用程序
【发布时间】:2015-07-29 07:26:18
【问题描述】:

我在下面有 server.R 和 ui.R 脚本。它让我一直给我“找不到对象'输入'”消息,我不知道为什么。我确保 selectInput 被命名正确等等,但没有解决方案。

服务器.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"))

 )))

【问题讨论】:

  • 只是想知道为什么不能使用data.table进行分组操作。

标签: r shiny


【解决方案1】:

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

试试

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

【讨论】:

    猜你喜欢
    • 2015-04-13
    • 1970-01-01
    • 1970-01-01
    • 2014-04-11
    • 1970-01-01
    • 2022-01-12
    • 1970-01-01
    • 1970-01-01
    • 2013-07-02
    相关资源
    最近更新 更多