1
votes

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)

1
Did you try conditionalPanel('input.myLocations=="LAS CRUZADAS" ',... ?Tonio Liebrand
It works only for the first plot 'AP LIGUA', but when i change the input in the app's interface to 'LAS CRUZADAS' it does not plot the other graphForever
Well you should provide a fully reproducible example. In your code above I can see output$apligua <- renderPlotly and output$chalaco <- renderPlotly but no output$lascruzadas<- renderPlotlyTonio Liebrand
drive.google.com/drive/folders/… here is the entire code. Your right it was a mistake there, but no in the main code. Im gonna edit this here.Forever

1 Answers

2
votes

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

"input.myLocations == 'LAS CRUZADAS'"

Notice the single quotes.