我的闪亮应用程序存在问题。我尝试使第二个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)
})
})
UI:
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"))
)
)
)
))
答案 0 :(得分:2)
您在选择输入ID中出现了sintax错误! ("Marka"
和"Model"
有大写字母)
selectInput("Marka",
"Wybierz markę",
levels(dane$Marka),
levels(dane$Marka)[1]),
selectInput("Model",
"Wybierz model",
levels(dane$Model),
levels(dane$Model)[1])