Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create a hyperlink interactively in shiny app?

Tags:

r

hyperlink

shiny

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?

like image 637
rdatasculptor Avatar asked Sep 12 '14 23:09

rdatasculptor


1 Answers

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)
    })
  })
)
like image 101
jdharrison Avatar answered Sep 21 '22 20:09

jdharrison