Forever
Forever

Reputation: 545

conditionalPanel and selectInput

Here is my problem; I can't set up properly the conditionalPanel to work with the selectInput. What I need is to plot apligua when "AP LIGUA" is selected, and lascruzadas when "LAS CRUZADAS" is selected. But Shiny is ploting both graphs.

Help please...

In the Server:

vars <- data.frame(location = c("AP LIGUA",
                              "LAS CRUZADAS"),
                 lat = c(-32.45,
                         -32.183333),
                 lon = c(-71.216667,
                         -70.802222)
)

output$apligua <- renderPlotly({
 theme_set(theme_bw()) 
 ggplot(aes(x = datos2$horafecha, y = datos2$altura2), data = datos2) + 
   geom_line() +
   geom_point() +
   geom_smooth(method = "auto", colour='blue', span=0.2) +
   ylab("Altura (m) ") + 
   xlab("Meses")
})

output$lascruzadas <- renderPlotly({
 theme_set(theme_bw()) 
 ggplot(aes(x = datos$horafecha, y = datos$altura2), data = datos) + 
   geom_line() +
   geom_point() +
   geom_smooth(method = "auto", colour='blue', span=0.2) +
   ylab("Altura (m) ") + 
   xlab("Meses")
})

In the UI

selectInput(inputId = "myLocations", label = "Estación",
                                              choices = vars$location),

conditionalPanel("input.myLocations" == "LAS CRUZADAS",
                                plotlyOutput("lascruzadas", height = "100%")
                                ),

conditionalPanel("input.myLocations" == "AP LIGUA",
                                plotlyOutput("apligua", height ="100%")
                                )

(ERROR EDITED)

Upvotes: 2

Views: 2279

Answers (1)

Tom Stringham
Tom Stringham

Reputation: 96

Your conditions should be one character string of Javascript code. So, something like:

"input.myLocations == 'LAS CRUZADAS'"

Notice the single quotes.

Upvotes: 2

Related Questions