Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making an Image Hyperlink in R Shiny header

I have been trying to make the image output hyperlink to a website but I am having trouble having perused the other questions on stack overflow

svg with clickable links in shiny - not clickable

http://www.invisiblecompany.com/shiny%20parts/archives/2004/11/clickable-logo.php

http://www.leahkalamakis.com/add-an-image-to-your-sidebar-make-it-clickable/

the tags are not working

server.r

library(shiny)
library(png)


server <- shinyServer(function(input, output) { 

output$image1 <- renderImage({
  width<- "100%"
  height<- "100%"
list(src = "www/logo.png",
     contentType = "image/png",
     width = width,
     height = height,
)

}, deleteFile = FALSE)
output$text1 <- renderText({ "please help make the image hyperlinked"     })


})

ui.r

library(shiny)



ui <- shinyUI(pageWithSidebar(
 titlePanel(imageOutput("image1")),

sidebarPanel(
  helpText(   a("Click Here for the Source Code on Github!",         href="https://github.com/Bohdan-Khomtchouk/Microscope",target="_blank"))

 ),
 mainPanel(
tabsetPanel(


  tabPanel("Instructions",textOutput("text1"))
))
))

you can replace the logo.png with whatever you want I think the hyperlink goes in the list in server.

like image 532
James Hennessy Avatar asked Jul 25 '16 02:07

James Hennessy


1 Answers

Just wrap imageOutput with tags$a so in the UI:

titlePanel(tags$a(imageOutput("image1"),href="https://www.google.com"))

If you want to define the webpage from the server side then you need something like this:

#server
  output$example <- renderUI({
    tags$a(imageOutput("image1"),href="https://www.google.com")
  })
#UI
titlePanel(uiOutput("example"))
like image 138
Carl Avatar answered Oct 23 '22 07:10

Carl