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)

  }
))