将一列文字网址转换成闪光中的活动超级链接 [英] Convert a column of text URLs into active hyperlinks in Shiny

查看:128
本文介绍了将一列文字网址转换成闪光中的活动超级链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个路径丰富程序的用户界面。结果如下表所示。

I am creating a user interface for a pathway enrichment program. The results are shown in a table as shown below.

下面是一个代码片段,显示我使用DT :: renderDataTable和DT :: datatable在一个选项卡中输出表。 spia_out()只是一个运行路径丰富并产生数据帧的反应函数。

Below is a snippet showing that I am using DT::renderDataTable and DT::datatable to output the table in a tab. spia_out() is just a reactive function that runs the pathway enrichment and produces a dataframe.

spia_out <- reactive({
    ...get results in a dataframe...
  })

output$spiaout <- DT::renderDataTable({
      DT::datatable(spia_out(), extensions = ..., options = ...)
  })

一切正常,通路浓缩表生成&打印在相应的UI元素中。我唯一的问题是如何将URL的最后一列(KEGGLINK)转换为活动超链接?所以人们只需点击它们,而不是复制&粘贴。

Everything works fine, the pathway enrichment table is generated & printed in the corresponding UI element. My only problem is how to convert the last column (KEGGLINK) of URLs into active hyperlinks? So that people can just click on them instead of copy & pasting.

提前泄露屏幕截图的大小。我希望你能看到最后一列KEGGLINK有URL但是没有活动。

Apologies in advance for the screenshot's size. I hope you can see the last column KEGGLINK has URLs but they are not active.

推荐答案

你需要做两件事情: / p>

You need to do two things:


  1. 修改最后一列,使KEGGLINK更改为一个正确的HTML链接,如下所示: ; href ='url'>链接文本< / a>

通过DT将 escape = FALSE 参数,以便它不会转义HTML代码。

Pass DT the escape = FALSE argument so that it doesn't escape the HTML code.

DT网页在第2.9节中有一个例子:
https://rstudio.github.io/DT/

The DT web page has an example of this in section 2.9: https://rstudio.github.io/DT/

一个简单的方式来做#1将是这样的:

A simple way to do #1 would be something like:

mydata$url <- paste0("<a href='",mydata$url,"'>",mydata$url,"</a>")

这篇关于将一列文字网址转换成闪光中的活动超级链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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