本文介绍了在R Shiny标题中制作图像超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试将图像输出超链接发送到网站,但是我在浏览堆栈溢出时遇到其他问题时遇到了麻烦

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

标签不起作用

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

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

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

推荐答案

只是愤怒p imageOutput 标签$ a 所以在用户界面中:

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

这篇关于在R Shiny标题中制作图像超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 16:49