Listings with R
The rlistings
R package is a package that was designed to create and display listings with R. The focus of this package is to provide functionality for value formatting and ASCII rendering infrastructure for tables and listings. Many of the functions contained in rlistings
depend on the formatters
package, which provides a framework for ASCII rendering and is available on CRAN.
rlistings
development is driven by the need to create regulatory ready listings for health authority review. Some of the key requirements for this undertaking are listed below:
- flexible formatting (pagesize, column widths, alignment, labels, etc.)
- multiple output formats (csv, out, txt)
- repeated key columns
- flexible pagination in both horizontal and vertical directions
- titles and footnotes
rlistings
currently covers some of these requirements, and remains under active development.
Installation
rlistings
is available on CRAN and you can install the latest released version with:
install.packages("rlistings")
or you can install the latest development version directly from GitHub with:
# install.packages("pak")
pak::pak("insightsengineering/rlistings")
Packaged releases (both those on CRAN and those between official CRAN releases) can be found in the releases list.
To understand how to use this package, please refer to the Introduction to rlistings
article, which provides multiple examples of code implementation.
Usage
The following example shows a simple listing and its printed output.
library(rlistings)
# Reducing the data
mtcars_ex <- mtcars %>% dplyr::mutate("car" = rownames(mtcars))
as_listing(mtcars_ex,
key_cols = c("gear", "carb"),
disp_cols = c("gear", "carb", "qsec", "car")
) %>% head()
#> sorting incoming data by key columns
#> gear carb qsec car
#> ———————————————————————————————————————
#> 3 1 19.44 Hornet 4 Drive
#> 20.22 Valiant
#> 20.01 Toyota Corona
#> 2 17.02 Hornet Sportabout
#> 16.87 Dodge Challenger
#> 17.3 AMC Javelin