xtable and hyperlinks

237 views
Skip to first unread message

Alex Brown

unread,
May 26, 2013, 9:23:56 PM5/26/13
to shiny-...@googlegroups.com
Is there a way to have a cell in xtable be a hyperlink?

-Alex 

Ramnath Vaidyanathan

unread,
May 26, 2013, 9:45:51 PM5/26/13
to shiny-...@googlegroups.com
Here is an example

tab1 = data.frame(x = c('a', 'b'), y = c('<a href="#b">New</a>'))
print(xtable(tab1), type = 'html', sanitize.text.function = function(x) x)

Note that you must be careful with the sanitize.text.function, since the default html escapes everything, whereas the identity function is used to prevent escaping of the hyperlinks.  

Alex Brown

unread,
May 28, 2013, 12:33:43 PM5/28/13
to shiny-...@googlegroups.com
Thanks - this is the full solution (where my_data_frame already contains links as above)

output$x <- renderTable({ my_data_frame }, sanitize.text.function=`(`)
Reply all
Reply to author
Forward
0 new messages