Tables Are Like Cockroaches

R-bloggers 2013-04-03

Summary:

As much as I would like to completely replace all tables with beautiful, intuitive, and interactive charts, tables like cockroaches cannot be eliminated. Based on this very interesting discussion on the Perceptual Edge forum with source Exploring the Origins of Tables for Information Visualization, tables date back to 1850 BCE. The paper concludes with

As part of exploration, tables help answer questions about data. As exemplars of communication, tables provide effective means for presenting data - each table has a story or stories to tell.

After struggling to create some attractive tables in HTML with R, I'm not sure they are any easier to create almost 4,000 years later. LaTeX is the clear winner when it comes to the table making competition. I have used xtable for HTML tables, but it could not fully produce a complicated table.  I was delighted to recently find the Gmisc package, which is the result of a frustrated orthopaedic surgeon's need to create tables in Word for journal submission.

pretty table from gforge.se

Another R to Word workflow was also discussed in Writing a MS-Word document using R (with as little overhead as possible). I was not aware of the need to produce a Word .doc from R. I simply thought creating an html table should not be that hard.

If you read Old Price Tables in Modern d3 Visualization and Dust off 130 Year Old Gold Books on Google Bookshelf, you'll know that my new favorite book is Gold and Prices Since 1873 by James Laurence Laughlin. This table on page 26 seems easy enough to recreate.

I had no idea how recreating this table would test and enhance my R skills. I started by manually entering the data since OCR did not work.

reps = c("http://ftp.sunet.se/pub/lang/CRAN", "http://cran.gforge.se") install.packages("Gmisc", repos = reps, dependencies = TRUE) 
library(Gmisc, verbose = FALSE)  # manually enter the data in a data frame data1874 <- data.frame(c(1872, 1874, 1869, 1870, 1870, 1871, 1871, 1871, 1870,      1873, 1872, 1871), c(153825, 41380, 131800, 15447, 4893, 2109, 16651, 80361,      1749, 7058, 3801, 18900), c(0, 0, 106600, 33695, 14230, 55320, 37160, 4775,      4325, 1535, 6980, 0), c(198540, 20580, 274100, 88487, 40505, 62857, 119000,      429486, 7327, 11794, 16877, 284561))  rownames(data1874) <- c("Banks of the United Kingdom", "Banks of Australia",      "Banks of France", "Banks of Italy", "National Bank of Belgium", "Bank of the Netherlands",      "Bank of Austria-Hungary", "Imperial State Bank of Russia", "Imperial Bank of Sweden",      "Bank of Norway", "National Bank of Denmark", "National Bank of the United States") colnames(data1874) <- c(" ", "Gold", "Silver", "Total Note Circulation")  data1885 <- data.frame(c(141205, 65890, 231483, 56121, 13900, 19161, 25902,      102207, 3436, 7169, 11566, 158100), c(0, 0, 217087, 11203, 6540, 38366,      48646, 676, 777, 0, 846, 7900), c(186850, 28115, 583610, 189690, 73400,      76972, 136351, 429860, 9835, 9287, 18370, 276500)) colnames(data1885) <- colnames(data1874)[2:4]   # get sums for totals row in table data1874[NROW(data1874) + 1, ] = apply(data1874, MARG

Link:

http://feedproxy.google.com/~r/RBloggers/~3/AszPNkf6zI4/

From feeds:

Statistics and Visualization » R-bloggers

Tags:

Authors:

klr

Date tagged:

04/03/2013, 18:54

Date published:

04/03/2013, 15:50