1

有人知道是否可以从打开专用仪表板的传单选定项目创建链接?

请在下面找到一个可复制的示例

当用户单击“转到专用仪表板”时,我希望我的应用程序打开一个带有专用仪表板的新窗口(例如显示与所选国家/地区相关的图表...)

library(shiny)
library(leaflet)

# download zip file
download.file(url = "http://thematicmapping.org/downloads/TM_WORLD_BORDERS-0.3.zip", destfile = "TM_WORLD_BORDERS-0.3.zip")

# unzip 
unzip( zipfile = "TM_WORLD_BORDERS-0.3.zip" )

# transfrom to sf and select two countries
world.borders <-read_sf( dsn = getwd(), layer = "TM_WORLD_BORDERS-0.3" )
world.borders <- world.borders[world.borders$NAME %in% c("Australia","United States"),]


ui <- fluidPage(
  leafletOutput("mymap")
)


server <- function(input, output, session) {

  output$mymap <- renderLeaflet({
    leaflet(options = leafletOptions(maxZoom = 18)) %>% addTiles() %>%
      addPolygons( data = world.borders, fill =  "#D24618", color = "#D24618",
                    popup = paste0(
                     "<b>Country: </b>"
                     , world.borders$NAME
                     , "<br>"
                     , "<a href='"
                     , "' target='_blank'>"
                     , "Go to dedicated dashboard</a>")
                     , label = ~NAME)
                  }) 
}

shinyApp(ui, server)

任何提示将不胜感激,在此先感谢您。

4

0 回答 0