Tmap and shiny errors - even renderTmap example does not work anymore

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

its a bug in the current version. https://github.com/mtennekes/tmap/issues/473

You can use the development version where the fix has been released.

library(remotes)
install_github("mtennekes/tmaptools")
install_github("mtennekes/tmap")

Thanks so much for the quick response!

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.