2016-07-25 69 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"))