summarytools R Package

repository·master·Indexed 19 days ago

https://github.com/dcomtois/summarytools

An R package for data cleaning, exploration, and simple reporting. It provides descriptive functions similar to commercial statistical software (SAS, SPSS, Stata) and integrates with RStudio, RMarkdown, Quarto, and knitr. Key features include flexible output formats, support for labelled vectors, and global configuration via st_options().

Tokens
782
Snippets
3
Records
5
Agent score
19%

What's inside summarytools

  1. Overview of summarytools capabilities

    master

    What is summarytools?

    summarytools is an R package designed for data cleaning, exploration, and simple reporting. It provides descriptive functions similar to commercial statistical software (SAS, SPSS, Stata) and integrates with RStudio, RMarkdown, Quarto, and knitr.

    Key Features

    • Descriptive Functions: Easy-to-use functions for data exploration.
    • Flexible Output: Supports various formats including HTML and R Markdown.
    • Reporting Integration: Works seamlessly with modern R reporting workflows.
    • Advanced Data Handling: Handles labelled vectors (from haven & labelled), manages NA values via the na.val parameter in functions like freq(), ctable(), and dfSummary(), and provides flexible statistical selection in descr().
  2. Install summarytools from GitHub

    master

    To benefit from the latest fixes and improvements not yet on CRAN, you can install directly from GitHub using the remotes package. It is strongly recommended to also install the pander package from GitHub to ensure compatibility.

    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)
  3. Install required system software for summarytools

    master

    While Windows users require no additional software, other operating systems may need Magick++ for fine-tuning graphics and interactive functionality. Mac users also require XQuartz.

    Mac OS X

    Ubuntu / Debian / Mint

    • sudo apt install libmagick++-dev

    Older Ubuntu (14.04 or 16.04)

    • sudo add-apt-repository -y ppa:opencpu/imagemagick
    • sudo apt-get update
    • sudo apt-get install -y libmagick++-dev

    Fedora / Red Hat / CentOS

    • sudo yum install ImageMagick-c++-devel

    Solaris

    • Use the OpenCSW package manager to install imagemagick.
  4. Configure summarytools options with st_options()

    master

    Use st_options() to set global preferences for how summarytools functions behave and how they render output. This is useful for adjusting styles for R Markdown, controlling silent modes, and managing footnotes.

    Example configuration:

    st_options(plain.ascii = FALSE,
               style = "rmarkdown",
               footnote = NA,
               subtitle.emphasis = FALSE,
               dfSummary.silent = TRUE,
               dfSummary.style = "grid",
               descr.silent = TRUE)