Search code examples
htmlrgooglevis

sortable HTML output from R with images


I have some data in a data frame. There is a small image associated with each row.

I'd like to be able to write this data to HTML along with the image and have it show up in each row as a thumbnail. That's no big deal by manually writing an href tag to link to the image.

However, I can't find a way to do this and make the HTML table sortable. The goal is to sort the HTML table by one of the columns and have the images sort along with the rows.

I've played around with using googleVis's gvisTable() function to do this but I haven't able to get the images to display.

Any ideas?

Thanks,

Max

> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] googleVis_0.4.7

loaded via a namespace (and not attached):
[1] RJSONIO_1.0-3 tools_3.0.2 

Solution

  • You can not interact with HTML, by definition. It is a markup language, meaning that is provides information about information. If you want to sort a table in the users' browser you need to use client side scripting, you best bet is jQuery.

    This is a great solution, it should work for your application.

    http://tablesorter.com/docs/