I would like to show in my brilliant application a link that links to a URL created based on user input. I do not want to show the full text of the URL. I know that the function a (href = ", label =" ") can be used if I know the URL in advance, but in this case the URL depends on user input. The following does not work:
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)
I hope I can click "Show on Google Map" and go to the URL created on the fly. Please help me, thanks.
url r shiny
Yu Zhang
source share