Hi all
Any ideas what is going on with Tmap and shinny? I am updating an old shiny app in which I use tmap and now the same code crashes. I have a map in which I update the shapefile display based on the years I choose. Something similar to the renderTmap example. I ended up going back to the renderTmap tutorial and even the example they have crashes with this error:
data(World)
world_vars <- setdiff(names(World), c("iso_a3", "name", "sovereignt", "geometry"))
ui <- fluidPage(
tmapOutput("map"),
selectInput("var", "Variable", world_vars)
)
server <- function(input, output, session) {
output$map <- renderTmap({
tm_shape(World) +
tm_polygons(world_vars[1], zindex = 401)
})
observe({
var <- input$var
tmapProxy("map", session, {
tm_remove_layer(401) +
tm_shape(World) +
tm_polygons(var, zindex = 401)
})
})
}
app <- shinyApp(ui, server)
Warning: Error in if: argument is of length zero
47: print_tmap
46: print.tmap
45: tmapProxy
Any ideas on what is going on?
I spent an entire afternoon trying to figure this out, but I cannot find a solution. I highly appreciate any help with this.
Best
Ramiro