Hi,
I want to change the title of my plot according to the select input. Do you have any idea of how can I do that? I tried this way but it remains the same.
renderPlotly({
title1<-paste(input$var1, "por país")
if (input$var1=="Taxa_Natalidade")
names("Taxa de Natalidade")
else if (input$var1== "Taxa_Mortalidade")
names("Taxa de Mortalidade")
p<- dados() %>%
plotly::plot_geo(z = ~Media, color = ~Media, colors = col,text = ~pais, locations = ~codigo, marker = list(line = l))
p <- p %>% layout(title= title1,
width = 1000, height = 500,
geo = g
)
p
})
What is the static title that you have then?
I would have thought your code and data would give the two titles.
Taxa_Natalidade por pais
Taxa_Mortalidade por pais
There is no assignment of title1 within the if else if statement meaning the title is never changed from title1<-paste(input$var1, "por país"). I believe what you want is the following:
if (input$var1=="Taxa_Natalidade")
title1 <- "Taxa de Natalidade por país"
else if (input$var1== "Taxa_Mortalidade")
title1 <- "Taxa de Mortalidade por país"