链接到Shiny App中的特定输入选择

时间:2019-12-12 17:34:11

标签: r shiny

我正在开发一个具有两个选项卡的Shiny App。首先是一张传单地图,其中包含几个城市的标记和弹出窗口。第二个选项卡有两个输入列(城市和细目分类),以及一个基于输入的绘图线图。是否可以从传单弹出窗口链接到其他选项卡,同时默认为所选城市?换句话说,如果我在地图上的纽约市弹出窗口中,是否可以创建指向其他选项卡的链接,以便第一个输入项位于纽约市?

pop_content = paste(data$city, "***Link to Second Tab Here***")

server <- function(input, output, session) {  
  output$plot <- renderPlotly({
    createplot(input$cityname,input$breakdown)
  })


  output$leaf=renderUI({
    leafletOutput('myMap', width = "100%", height = input$Height)
  })

  output$mymap <- renderLeaflet({
    Map <- leaflet(data_Map, options = leafletOptions(zoomControl = FALSE,
                                                      minZoom = 4.25, maxZoom = 4.25,
                                                      dragging = T)) %>%
      setView(lng = -97, lat = 40, zoom = 4) %>% 
      addTiles() %>%
      addPolygons(color = "black", opacity = .05, fillColor = "black", fillOpacity = c(.13)) %>%
      addCircleMarkers(data = MapData, lng=MapData$Longitude, lat=MapData$Latitude, color = "royalblue", radius = 11,
                       opacity = .3,fillOpacity = .75, popup = pop_content,  labelOptions = labelOptions(interactive = T))
    Map 
  })


}

ui = navbarPage(theme=shinytheme("flatly"),
                "Arrest Rate",
                tabPanel("Map",leafletOutput('mymap', width = 820, height = 550)),
                tabPanel("Arrest Rates Over time",
                         fluidRow(column(3,selectInput("cityname"," Select City:",Cities)),
                                  column(3,selectInput("breakdown","Select Demographic Category:",
                                                       Breakdowns))),
                         plotlyOutput("plot", width = "1036px", height = "546px"),
                         verbatimTextOutput("event"), style = "border: 2px solid black;width: 1040px; height: 650px")
)

我已阅读以下查询,虽然有助于标签之间的链接,但无法解决输入问题。 Externally link to specific tabPanel in Shiny App

我也尝试过https://appsilon.com/shiny-router-a-simple-routing-package-for-shiny/?nabe=4634331497365504:1,它也为标签页设置了链接。

0 个答案:

没有答案