Tmap Facets didn't work in R shiny

I am trying to use tmap facets to create a side-by-side synchrounous choropleth map (refer to but the facet seems didn't work (my code have no error but the maps didn't show up) in R shiny. When I run the regular R code of facets maps, it works fine.

Here is my code:

library(shiny)    # for shiny apps
library(leaflet)  # renderLeaflet function
# data import and processing
CANCER_raw <- st_read("F:/appR-upload/cancer_sample_data.csv")
SD_SRA_raw <- st_read("F:/appR-upload/polygon/polygon.shp")

cancer_data <- data.frame(
      SRAID = CANCER_raw$GeoID,   
      SRA_Name = CANCER_raw$Geography, 
      Condition = CANCER_raw$CONDITION,
      Outcome = CANCER_raw$OUTCOME,
      Year = CANCER_raw$Year,
      Total = CANCER_raw$Total,
      TotalRate = CANCER_raw$TotalRate,
      AARate = CANCER_raw$AARate
sd_sra <- data.frame(
      SRAID = SD_SRA_raw$SRA, 
      SRA_Name = SD_SRA_raw$SRA_Name,
      geometry = SD_SRA_raw$geometry

sd_sra_cancer <- st_as_sf(left_join(sd_sra, cancer_data, by = 'SRAID'))

ui <- fluidPage(
  leafletOutput(outputId = "map")

server <- function(input, output, session) {
    output$map <- renderLeaflet(
        tm <- tm_shape(sd_sra_cancer) +
          tm_polygons(c("Total", "TotalRate")) +
          tm_facets(sync = TRUE, ncol = 2)

shinyApp(ui, server)

This topic was automatically closed 21 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.