Summarytools
R Package to Quickly and Neatly Summarize Data
Install / Use
/learn @dcomtois/SummarytoolsREADME
<span class="badge-paypal"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=HMN3QJR7UMT7S&item_name=Help+scientists,+data+scientists+and+analysts+around+the+globe¤cy_code=CAD&source=url" title="Donate to this project using Paypal"><img src="https://img.shields.io/badge/PayPal-Donate-blue" alt="PayPal donate button"/></a></span>
Summarytools 1.1 is out!
<a href="#latest">Check out what’s new.</a>
Love summarytools? Share the love, buy me a coffee!
<a href="https://buymeacoffee.com/dcomtois"><img src="img/bmc_qr.png" width="100" height="100"/></a>

summarytools is a an R package for data cleaning, exploring, and simple reporting. The package was developed with the following objectives in mind:
- Provide a coherent set of easy-to-use descriptive functions akin to those included in commercial statistical software suites such as SAS, SPSS, and Stata
- Offer flexibility in terms of output format & content
- Integrate well with commonly used software & tools for reporting (the RStudio IDE, Rmarkdown, Quarto, and knitr) while also allowing for standalone, simple report generation using any R interface
On a more personal level, I simply wish to share with the R community and the scientific community at large the functions I first developed for myself, but realized would benefit others who are facing similar challenges when dealing daily with (often messy) data.
Package Documentation
The bulk of the technical documentation can now be found in the following vignettes:
Introduction to
summarytools
| CRAN
version
Summarytools in R
Markdown
| CRAN
Version
PDF
Manual
(automatically generated by CRAN)
Installing summarytools
Required Software
Additional software is used by summarytools for fine-tuning graphics as well as offering interactive functionality. If you are installing summarytools for the first time, click on the relevant link to get OS-specific instructions. On Windows, no additional software is required.
<a href="#required-mac-os">Mac OS X</a>
<a href="#required-debian">Ubuntu / Debian / Mint</a>
<a href="#required--older-ubuntu">Older Ubuntu (14 and 16)</a>
<a href="#required-fedora">Fedora / Red Hat / CentOS</a>
<a href="#required-solaris">Solaris</a>
Installing From GitHub
This method has the advantage of benefiting from minor fixes and improvements that are added between CRAN releases. Its main drawback is that you won’t be noticed when a new version is available. You can either check this page from time to time, or best, use a package that checks for package updates on various repositories, such as dtupdate and Drat.
install.packages("remotes") # Using devtools or pak is also possible
library(remotes)
install_github("rapporter/pander") # Strongly recommended
install_github("dcomtois/summarytools", build_vignettes = TRUE)
Installing From CRAN
CRAN versions are stable but are not updated as often as the GitHub versions. On the plus side, they can be easier to install on some systems.
install.packages("summarytools")
<a id="latest"></a>Latest Changes
-
Version 1.1.0 introduced a few significant improvements, aside from the bug fixes.
- In
stby(), theuseNAparameter can be used to generate additional groupings for observations where the grouping variable(s) areNA - Labelled vectors from haven & labelled are treated like
factors by
freq()(always) anddfSummary()(only when all values have labels; this is to avoid generating factors with countless numerical levels). descr()is more flexible with the stats parameters; you can for instance usestats = c("all", -"kurtosis")if you need everything except kurtosis- The helper function
zap_attr()turns results into simple matrices, adding an alternative totb()when you need to work further with the results - A new
na.valparameter was added tofreq(),ctable()anddfSummary(), which allows treating a particular character value or factor level asNA. One common instance would be “” (empty string) for character vectors. - Sampling weights were a bit buggy with by-groups, and so was
tb()withfreq()results. This is now a thing of the past. - See the package’s NEWS for more details:
news(package="summarytools")
- In
-
In
dfSummary()since 1.0.1:- It is possible to control which statistics to show in the Freqs /
Values column (see
help("st_options", "summarytools")for examples) - In html outputs, tables are better aligned horizontally
(categories >> counts >> charts); if misalignment occurs,
adjusting
graph.magnifshould resolve it - List-type columns and
Infvalues are handled properly
- It is possible to control which statistics to show in the Freqs /
Values column (see
For more details, see vignette("introduction", "summarytools") as well
as news(package = "summarytools").
Additional Software Installations
<a id="required-mac-os"></a>Required Software on Mac OS
Magick++ can be installed using Homebrew or Macports.
<a href="#installing-from-github">Back to installation instructions</a>
<a id="required-debian"></a>Required Software for Debian / Ubuntu / Linux Mint
Magick++
sudo apt install libmagick++-dev
<a href="#installing-from-github">Back to installation instructions</a>
<a id="required-older-ubuntu"></a>Required Software for Older Ubuntu Versions
This applies only if you are using Ubuntu Trusty (14.04) or Xenial (16.04).
sudo add-apt-repository -y ppa:opencpu/imagemagick
sudo apt-get update
sudo apt-get install -y libmagick++-dev
<a href="#installing-from-github">Back to installation instructions</a>
<a id="required-fedora"></a>Required Software for Fedora / Red Had / CentOS
Magick++
sudo yum install ImageMagick-c++-devel
<a href="#installing-from-github">Back to installation instructions</a>
<a id="required-solaris"></a>Required Software for Solaris
pkgadd -d http://get.opencsw.org/now
/opt/csw/bin/pkgutil -U
/opt/csw/bin/pkgutil -y -i imagemagick
/usr/sbin/pkgchk -L CSWimagemagick
<a href="#installing-from-github">Back to installation instructions</a>
Support summarytools’ Development
If summarytools brings value to your work, please consider making a donation. It will bring a smile to my face and boost my productivity! Buy me a coffee, or use the PayPal link. Thanks!
<a href="https://buymeacoffee.com/dcomtois"><img src="img/bmc_qr.png" width="100" height="100" style="justify: center"/></a><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=HMN3QJR7UMT7S&item_name=Help+scientists,+data+scientists+and+analysts+around+the+globe¤cy_code=CAD&source=url"><img src="img/paypal-blue.svg" width="170" height="30"/></a>
<a id="supporters"></a>Supporters
A big thanks to the following people who made donations:
- Ashirwad Barnwal
- David Thomas
- Peter Nilsson
- Ross Dunne
- Igor Rubets
- Joerg Sahlmann
- Mark Friedman
- Roger Hilfiker
- Stefano Lav
The package comes with no guarantees. It is a work in progress and feedback is always welcome. Please open an issue on GitHub if you find a bug or wish to submit a feature request.
<a href="#top">Back to top</a>
