Create URL hyperlink in R Shiny?

为君一笑 提交于 2019-12-18 04:03:28

问题


My code:

library(shiny)
runApp(
  list(ui = fluidPage(
     uiOutput("tab")
    ),
  server = function(input, output, session){
    url <- a("Google Homepage", href="https://www.google.com/")
    output$tab <- renderUI({
      paste("URL link:", url)
    })
  })
)

Current output:

URL link: <a href="https://www.google.com/">Google Homepage</a>

Desired output:

URL link: Google Homepage

where Google Homepage is a clickable hyperlink.

I'm currently using the renderUI/uiOutput duo as instructed here: how to create a hyperlink interactively in shiny app?


回答1:


By using paste, you're treating the url as a string. The function you want to use here is tagList:

runApp(
  list(ui = fluidPage(
     uiOutput("tab")
    ),
  server = function(input, output, session){
    url <- a("Google Homepage", href="https://www.google.com/")
    output$tab <- renderUI({
      tagList("URL link:", url)
    })
  })
)


来源:https://stackoverflow.com/questions/42047422/create-url-hyperlink-in-r-shiny

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!