MyNixOS website logo
Description

Create Table Summaries and Export Neat Tables to 'Excel'.

A high-level interface for creating and exporting summary tables to 'Excel'. Built on 'dplyr' and 'openxlsx', it provides tools for generating one-way to n-way tables, and summarizing multiple response questions and question blocks. Tables are exported with native 'Excel' formatting, including titles, footnotes, and basic styling options.

xlr or ‘Exceller’

R-CMD-check

xlr

xlr is designed to help build summary tables with complex survey data, and export data to Excel. It includes functions to easily make cross-tabulations, work with multiple response data, and question blocks. It supports labelled data that can be generated from the popular survey platform Qualtrics.

It makes exporting data from Excel easier. It is a easier to use wrapper around openxlsx. It supports tables with footnotes, headers, and generating table of contents in Excel documents. It is not fully featured, but designed to be used when you are moving either statistical summaries or tables from R into Excel.

This package is designed to work seamlessly with tidyverse family of functions.

It is currently experimental and subject to change based on peoples feedback.

Installation

# To install via CRAN
install.packages("xlr")

You can install the development version of xlr from GitHub with:

# install.packages("pak")
pak::pak("NHilder/xlr")

Example

This is a example of how to create a two-way table, fix the formatting for that table, and then export that table to Excel.

library(xlr)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

# create a summary table
two_way_table <- build_table(mtcars,c(cyl,gear))
two_way_table
#> # A xlr_table: 8 x 4
#>       cyl    gear       N Percent
#>   <x_dbl> <x_dbl> <x_int> <x_pct>
#> 1    4.00    3.00       1      9%
#> 2    4.00    4.00       8     73%
#> 3    4.00    5.00       2     18%
#> 4    6.00    3.00       2     29%
#> 5    6.00    4.00       4     57%
#> 6    6.00    5.00       1     14%
#> 7    8.00    3.00      12     86%
#> 8    8.00    5.00       2     14%

# make the percentage have two decimal places using dplyr
two_way_table <- two_way_table |> 
  mutate(Percent = xlr_percent(Percent, dp = 2))

# write the data to an xlsx file
write_xlsx(two_way_table,
           "example.xlsx",
           "an example")
#> ℹ Appending file: 'example.xlsx'

Check out the vignettes for more information on how to use the package.

Metadata

Version

1.0.3

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows