在 R Shiny 中创建 URL 超链接? [英] Create URL hyperlink in R Shiny?

查看:23
本文介绍了在 R Shiny 中创建 URL 超链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码:

library(shiny)
runApp(
  list(ui = fluidPage(
     uiOutput("tab")
    ),
  server = function(input, output, session){
    url <- a("Google Homepage", href="https://www.google.com/")
    output$tab <- renderUI({
      paste("URL link:", url)
    })
  })
)

当前输出:

网址链接:<a href="https://www.google.com/">Google 主页</a>

所需的输出:

URL 链接:Google 主页

其中 Google Homepage 是一个可点击的超链接.

where Google Homepage is a clickable hyperlink.

我目前正在按照此处的说明使用 renderUI/uiOutput 二重奏:如何在闪亮的应用程序中以交互方式创建超链接?

I'm currently using the renderUI/uiOutput duo as instructed here: how to create a hyperlink interactively in shiny app?

推荐答案

通过使用 paste,您将 url 视为字符串.这里要使用的函数是tagList:

By using paste, you're treating the url as a string. The function you want to use here is tagList:

runApp(
  list(ui = fluidPage(
     uiOutput("tab")
    ),
  server = function(input, output, session){
    url <- a("Google Homepage", href="https://www.google.com/")
    output$tab <- renderUI({
      tagList("URL link:", url)
    })
  })
)

这篇关于在 R Shiny 中创建 URL 超链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆