how to create a hyperlink interactively in shiny app?

谁说胖子不能爱 提交于 2019-12-28 16:03:13

问题


I am building a shiny app in which I want to create hyperlinks interactively. I know how to add a link to the ui.r by using a() but how can I let my shiny app change that link interactively?

Does anyone have an idea about how to do this?


回答1:


You can use renderUI to dynamically render HTML:

library(shiny)
runApp(
  list(ui = fluidPage(
    selectInput('website', 'Choose a website'
                , list(bbc = "http://www.bbc.co.uk"
                       , google = "http://www.google.com"
                       , cnn = "http://www.cnn.com")
    )
                , htmlOutput("mySite")
    )
  ,server = function(input, output, session){
    output$mySite <- renderUI({
      tags$a(href = input$website, input$website)
    })
  })
)


来源:https://stackoverflow.com/questions/25818416/how-to-create-a-hyperlink-interactively-in-shiny-app

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