R Shiny - Ошибка: Ошибка в [.tbl_df: объект «вход» не найден - PullRequest
0 голосов
/ 30 января 2019

Я создаю простое блестящее приложение на основе таблицы.(Пример данных в конце).Вот моя первоначальная установка Server:

Обновление: перемещено reactive() внутри function(input, output) { - но все еще получается пустой график с ошибками Warning: Length of logical index must be 1 or 56, not 0.

## Server ----
function(input, output) {


# Make data reactive
bet_data2 <- reactive(
  {bet_data[bet_data$singleType == input$singleType &
            bet_data$result == input$result, ]})


# Plot 1 
output$plot1 <- renderPlot({

# Render first plot
print(
  ggplot(bet_data2()) +
    geom_bar(aes(result, fill = singleType),
             position = position_dodge(), color = "black",
             show.legend = T)
    ) +
    theme_light()
   ) 
 })
}

А вот настройка UI:

## User Interface ----

daterange <- unique(bet_data$date)
team <- unique(bet_data$teamA)

# Use a fluid Bootstrap layout
fluidPage(    

  # Give the page a title
  titlePanel("TEST"),

  # Generate a row with a sidebar
  sidebarLayout(

    selectInput("date", "Date:",
                choices = daterange),

    selectInput("team", "Team", 
                choices = team)
  ),

  # Create a spot for the barplot
  mainPanel(
    plotOutput("plot1")  
  )
)

Когда я запускаю приложение, я получаю Error: object 'input' not found в окне приложения и Error in [.tbl_df: object 'input' not found в консоли.

Что я делаю не так?Я думаю, что все изменилось вместе соответственно.


Пример данных:

structure(list(date = structure(c(1548288000, 1548288000, 1548201600, 
1548201600, 1548201600, 1547683200), class = c("POSIXct", "POSIXt"
), tzone = "UTC"), singleBets = c("MTL/ARZ O6 (+120)", "CAR/VAN O5.5 
(2u) (-120)", 
"NYI Reg ML (+110)", "ARZ ML (-105)", "CGY/CAR O6.5 (-105)", 
"NYR ML (+125)"), result = c("loss", "win", "loss", "win", "loss", 
"win"), teamA = c("MTL", "CAR", "NYI", "ARZ", "CGY", "NYR"), 
teamB = c("ARZ", "VAN", NA, NA, "CAR", NA), odds = c(120, 
-120, 110, -105, -105, 125), singleType = c("over", "over", 
"money-line", "money-line", "over", "money-line")), class = c("tbl_df", 
 "tbl", "data.frame"), row.names = c(NA, -6L), .Names = c("date", 
 "singleBets", "result", "teamA", "teamB", "odds", "singleType"
 ))
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...