I'm learning shiny and tmap. I'm able to get the map I want on Rstudio (a static tmap). But when I try a similar tmap code with shiny, I always get an interactive map.
From this reprex, I try to get the same map I get on Rstudio.
I try to add tmap_mode("plot")
after the renderTmap
, but it doesn't work.
My question look too simple... but can't find the answer! Thank for your help.
library(shiny)
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({
tmap_mode("plot")
tm_shape(World) +
tm_polygons(world_vars[1], zindex = 401)
})
}
shinyApp(ui, server)