我想在我的閃亮應用程序中顯示一個鏈接,該鏈接指向基於用戶輸入生成的URL。我不想顯示網址的全文。我知道如果事先知道URL,可以使用a(href =「」,label =「」)函數,但在這種情況下,URL取決於用戶的輸入。以下不起作用:嵌入反應生成的URL閃亮
ui <- fluidPage(
titlePanel("Show map of a given state"),
sidebarLayout(
sidebarPanel(
textInput("state", label = "State", value = "CA", placeholder = "California or CA"),
actionButton("showU","Show map")
),
mainPanel(
conditionalPanel(
condition = "input.showU > 0",
htmlOutput("url"),
a(href=htmlOutput("url"),"Show in Google Map",target="_blank")
)
)
)
)
server <- function(input, output){
observeEvent(input$showU,{
output$url <-renderUI({paste("https://www.google.com/maps/place/", input$state, sep="")})
})
}
shinyApp(ui,server)
我希望我可以點擊「在Google地圖中顯示」並定向到動態生成的網址。請幫助我,謝謝。
網址非常感謝你一個HTML按鈕!這正是我需要的。 –
@YuZhang高興我的回答有幫助,請接受它 – HubertL