How to add Links in a DataTable for Shiny Dashboard



I need make the column ‘site’ clickable.


Hi @anvesh2953 , I literally figured out how to do that an hour ago, the trick is to use datatable() inside renderDataTable(), and to pass the click related arguments to it, here is a snippet:

output$test <- renderDataTable(datatable(mtcars, list(mode = "single", target = "cell")))

That creates a new input called input$test_cell_clicked, I then learned how to use it with this page:


That’s Great!!.. But, can i make value of the cell a hyperlink which is clickable?


@anvesh2953 I don’t remember where I saw it, but you can use the escape = FALSE argument in datatable to add HTML into your data and have datatable render it. For example:

output$mytable <- DT::renderDataTable(DT::datatable({
    data <- dt()[,c("Date","IMEI","PDLColor","ULSpeed","DLSpeed","site")] %>% 
      mutate(site = paste0("<a href='", site,"' target='_blank'>", site,"</a>"))
  escape = FALSE))


@jdb Thanks for that. Can i capture the value of the clicked link in “input$” so that i can perform plots based on the value


@anvesh2953 The only solution I can think of is to use JavaScript to send the information being an onclick function back to Shiny. This article has some great examples, you’d probably be looking for the Shiny.onInputChange function.