Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
340 views
in Technique[技术] by (71.8m points)

r - how to create a hyperlink interactively in shiny app?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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)
    })
  })
)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...