2016-07-25 66 views
1

我一直在试图使图像输出超链接到一个网站,但我有已经细读上堆栈溢出的其他问题麻烦对影像超链接中的R闪亮头

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/

标签不工作

SE rver.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")) 
)) 
)) 

可以替换为任何你想要我认为的超级链接去在服务器列表中的logo.png。

+1

如果没有什么动态关于图片,只需使用HTML builder函数:'a(img(src =“logo.png”),href =“https://github.com/Bohdan-Khomtchouk/Microscope”)' – alistaire

回答

3

只是包装imageOutputtags$a所以在UI:

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

如果你想,那么你需要像这样定义从服务器端的网页:

#server 
    output$example <- renderUI({ 
    tags$a(imageOutput("image1"),href="https://www.google.com") 
    }) 
#UI 
titlePanel(uiOutput("example"))