Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R shiny open the URLs from renderTable in a new tab

Tags:

url

tabs

r

shiny

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.

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

Thank you!

like image 368
Marta Avatar asked Feb 20 '14 13:02

Marta


1 Answers

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

For example :

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)

  }
))
like image 157
Julien Navarre Avatar answered Nov 15 '22 18:11

Julien Navarre