# From SAS to R - what are “must” packages for reporting

One big advantage of SAS over R is arguably its ability to produce quite complex reports with few statements; think of PROC SUMMARY or PROC TABULATE for instance.

My heart goes to R because of its openness and vibrant community. But I must admit that SAS's PROCS are quite powerful out-of-the-box. To partially address those issues I wrote an R package titled summarytools which provides ways to generate decent looking and translatable (thanks to pander, Pandoc implemented in R) simple reports (frequencies, univariate stats, codebook, for the essential part) to various formats like RTF, pdf, and markdown.

However, even with the use of by() to stratify the stats (be it frequencies or univariate numerical stats), I feel I'm still miles away from generating as flexible and complete tables such as with PROC TABULATE or PROC MEANS. So my question is: what R packages do you find are "musts" for needs of extracting essential stats from dataframes, splitting on this variable and filtering on that other one. I hope this is not judged as too broad a question; I have made my homework and tried finding the answer to this question before posting here. I'm sure there are some really really well-made packages that adress those issues, and I simply haven't seen them around... yet. So if I may ask, please hold off for a day or two before putting the lock on this one. ;)

Any input is mostly welcome!

Cheers

• I believe SAS reports are inferior to Rs, you just need to find the correct packages and functions to use. I use packages tableone, Hmisc, sjPlot for these tasks. – Adam Robinsson Nov 9 '14 at 13:56
• I like the sjPlot approach a lot since it gives absolutely beautiful results without having to go through additional steps. – Dominic Comtois Nov 9 '14 at 23:09

The problem with R is that there are so many ways to construct great reports, and so many R packages that are helpful for this task. One approach, though getting out of date, is shown in http://biostat.mc.vanderbilt.edu/wiki/pub/Main/StatReport/summary.pdf . Note that some of the functions there have been updated as shown in http://biostat.mc.vanderbilt.edu/HmiscNew [and really take note of the tabulr function]. That approach revolves around $\LaTeX$, and I believe you'll find that for producing advanced tables (includes ones containing micrographics and footnotes), $\LaTeX$ has many advantages over the markdown-pandoc approach.

But I believe that we should replace almost all tables with graphics. The new R greport ("graphical report") package takes the philosophy that graphics should be used for the main presentation, and graphs should be hyperlinked to supporting tables that appear in an appendix to the pdf report. See http://biostat.mc.vanderbilt.edu/Greport. greport uses new functions in the Hmisc package for graphing categorical data (i.e., translating tables to plots) and for showing whole distributions of continuous variables.

• I'll look into greport, thanks. The all-graphics avenue seems like a promising one indeed. I also found that gplots, sjPlot (as mentionned by @Adam Robinson) and gridExtra all provide functions that generate graphic tables. – Dominic Comtois Nov 10 '14 at 4:44

It seems like reporting and filtering/splitting data by variables are two orthogonal tasks. And people usually use different packages for those.

For managing the data there are few really popular packages: dplyr and data.table.

For reporting tables one package that stands out for me is stargazer

Here are some demonstrations: http://cran.r-project.org/web/packages/stargazer/vignettes/stargazer.pdf

It covers both latex and html (and ASCII, but haven't used that).

I have never used SAS so I don't know if this will cover all the functionality you wanted.

• I am quite aware of the existing tools to manipulate data. I'll look into stargazer, thanks for the suggestion. – Dominic Comtois Nov 10 '14 at 11:37
• Stargazer is nice, but i prefer Tableone because it provides similar functionality for regression results (ShowRegTable function) but also baseline tables (CreateTableOne function). I've sometimes obtained somewhat different confidence intervals in stargazer, as compared to package used for calulating point estimates. Its nice though that it provides AIC, observations used etc... – Adam Robinsson Nov 10 '14 at 11:56
• I haven't used tableone, but after a quick look it seems to be more about getting tables themselves, while stargazer is more about exporting those tables to html/latex with predefined styles. It might be possible to use tableone for obtaining the table and stargazer for exporting it to documents. like stargazer(ShowRegTable(obj)) – Karolis Koncevičius Nov 10 '14 at 12:17
• As Frank put it, there are so many possible ways to achieve great things with R. I'm still thinking the ascii + markdown avenue has a lot to offer for little investment. But I appreciate your input and will continue experimenting. – Dominic Comtois Nov 11 '14 at 16:18