【发布时间】:2015-05-08 21:41:12
【问题描述】:
我的闪亮应用有问题。我尝试使第二个 selectInput (model) 依赖于在第一个 selectInput (marka) 中所做的选择,但它仍然无法正常工作。
我发现了这个主题Using the input from updateSelectInput,它在我的电脑上运行,所以我对我的数据做了完全相同的事情(在PogromcyDanych 包中)。不幸的是,它不起作用,我绝望了。我收到警告消息:
Warning in run(timeoutMs) :
is.na() applied to non-(list or vector) of type 'NULL'
Warning in run(timeoutMs) :
下面是我的server.R 和ui.R 文件:
library(shiny)
library(PogromcyDanych)
library(dplyr)
shinyServer(function(input, output, session) {
dane <- auta2012
observe({
marka <- input$Marka
ktore <- dane %>%
filter(Marka == marka) %>%
arrange(Model) %>%
select(Marka, Model)
updateSelectInput(session, "model",
choices = levels(factor(ktore$Model)),
selected = levels(factor(ktore$Model))[1])
})
dane.cena <- reactive({
dane %>%
filter(Marka == input$Marka, Model == input$Model)
})
})
用户界面:
library(shiny)
library(PogromcyDanych)
dane <- auta2012
shinyUI(fluidPage(
titlePanel("Znajdź swój samochód!"),
sidebarLayout(
sidebarPanel(
selectInput("marka",
"Wybierz markę",
levels(dane$Marka),
levels(dane$Marka)[1]),
selectInput("model",
"Wybierz model",
levels(dane$Model),
levels(dane$Model)[1])
),
mainPanel(
h1("Ceny samochodów:"),
br(),
tabsetPanel(
tabPanel("Boxplot", plotOutput("boxplot", width = 500)),
tabPanel("Histogram", plotOutput("histogram", width = 500)),
tabPanel("Podsumowanie", verbatimTextOutput("podsumowanie")),
tabPanel("Tabela", tableOutput("tabela"))
)
)
)
))
【问题讨论】: