R Shiny 在新选项卡中打开 renderTable 中的 URL [英] R shiny open the URLs from renderTable in a new tab

查看:34
本文介绍了R Shiny 在新选项卡中打开 renderTable 中的 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有带有 url 链接的 renderTable:

I have renderTable with url links:

output$url_list <- renderTable({
   url_list<-as.data.frame(urls_from_plg_table())
}, sanitize.text.function = function(x) x, target="_blank",
   options = list(aLengthMenu = c(5, 30, 50), iDisplayLength = 5))

我想在我闪亮的应用程序的新标签页中打开此表中的网址.

I want to open the URLs from this table in a new tab from my shiny app.

我尝试添加:target="_blank",但这种方式不起作用.我该怎么办?

I try add: target="_blank", but it doesn't work in this way. How can I go about it?

谢谢!

推荐答案

在 data.frame 中使用带有 HTML 标记的字符串.(并且不要忘记 sanitize.text.function = function(x) x 按原样评估您的 HTML 标签).

Use a string with the HTML tag in your data.frame. (And don't forget sanitize.text.function = function(x) x to evaluate your HTML tags as is).

例如:

shiny::runApp(list( 
  ui = bootstrapPage(

    tableOutput("table")

    ),

  server = function(input, output) {

    output$table <- renderTable({

      urls <- c("http://www.google.fr", "http://www.google.fr")
      refs <- paste0("<a href='",  urls, "' target='_blank'>GOOGLE</a>")

      data.frame(refs)

    }, sanitize.text.function = function(x) x)

  }
))

这篇关于R Shiny 在新选项卡中打开 renderTable 中的 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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