Reputation: 3269
I have a problem with my shiny app. I try to make second selectInput (model
) to be dependent from choice made in first selectInput (marka
) but it still not working.
I found this topic Using the input from updateSelectInput and it works on my computer so i did exactly the same thing with my data (there are in PogromcyDanych
package). Unfortunately it's not working, I'm hopeless. I get the warning message:
Warning in run(timeoutMs) :
is.na() applied to non-(list or vector) of type 'NULL'
Warning in run(timeoutMs) :
Below there are my server.R
and ui.R
files:
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"))
)
)
)
))
Upvotes: 1
Views: 2584
Reputation: 1118
You have a sintax error in the select input id! ("Marka"
and "Model"
with capital letter)
selectInput("Marka",
"Wybierz markę",
levels(dane$Marka),
levels(dane$Marka)[1]),
selectInput("Model",
"Wybierz model",
levels(dane$Model),
levels(dane$Model)[1])
Upvotes: 2