MyNixOS website logo
Description

Simple Tabulation Made Simple.

Simple tabulation should be dead simple. This package is an opinionated approach to easy tabulations while also providing exact numbers and allowing for re-usability. This is achieved by providing tabulations as data.frames with columns for values, optional variable names, frequency counts including and excluding NAs and percentages for counts including and excluding NAs. Also values are automatically sorted by in decreasing order of frequency counts to allow for fast skimming of the most important information.

Simple Tabulation Made Simple

Status

lines of R code: 150, lines of test code: 117

repostatusAppVeyor buildstatus Codecov

Development version

0.2.1 - 2020-03-30 / 20:12:13

Description

Simple tabulation should be dead simple. This package is an opinionated approach to easy tabulations while also providing exact numbers and allowing for re-usability. This is achieved by providing tabulations as data.frames with columns for values, optional variable names, frequency counts including and excluding NAs and percentages for counts including and excluding NAs. Also values are automatically sorted by in decreasing order of frequency counts to allow for fast skimming of the most important information.

License

MIT + file LICENSE
Peter Meissner [aut, cre]

Installation

You can install the released version of tabit from CRAN with:

install.packages("tabit")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("petermeissner/tabit")

Example

# load package
library(tabit)

simple vectors

# simple tabulation
tabit(mtcars$cyl)
##   .variable .value .count  .pct .pct_incl_na
## 3         .      8     14 43.75        43.75
## 1         .      4     11 34.38        34.38
## 2         .      6      7 21.88        21.88
## 4         .     NA      0    NA         0.00

simple data.frames

# can we do this with data.frames
tabit(mtcars[, c("cyl", "am")])
##   cyl am .count  .pct .pct_incl_na
## 3   8  0     12 37.50        37.50
## 4   4  1      8 25.00        25.00
## 2   6  0      4 12.50        12.50
## 1   4  0      3  9.38         9.38
## 5   6  1      3  9.38         9.38
## 6   8  1      2  6.25         6.25

simple tibbles

# what about this tibble thing?
suppressPackageStartupMessages({
  library(dplyr)
})
## Warning: package 'dplyr' was built under R version 3.6.3
mtcars %>% 
  select(cyl, am) %>% 
  tabit()
##   cyl am .count  .pct .pct_incl_na
## 3   8  0     12 37.50        37.50
## 4   4  1      8 25.00        25.00
## 2   6  0      4 12.50        12.50
## 1   4  0      3  9.38         9.38
## 5   6  1      3  9.38         9.38
## 6   8  1      2  6.25         6.25

grouped tibbles

# ... and grouped tibbles?
mtcars %>% 
  group_by(cyl, am) %>% 
  tabit()
##   cyl am .count  .pct .pct_incl_na
## 3   8  0     12 37.50        37.50
## 4   4  1      8 25.00        25.00
## 2   6  0      4 12.50        12.50
## 1   4  0      3  9.38         9.38
## 5   6  1      3  9.38         9.38
## 6   8  1      2  6.25         6.25

too much magic?

# use tabit_1() for vector usage
tabit_1(letters[1:4])
##   .variable .value .count .pct .pct_incl_na
## 1         .      a      1   25           25
## 2         .      b      1   25           25
## 3         .      c      1   25           25
## 4         .      d      1   25           25
## 5         .     NA      0   NA            0

# use tabit_x for data.frames and tibbles
tabit_x(mtcars[, c("cyl", "am")])
##   cyl am .count  .pct .pct_incl_na
## 3   8  0     12 37.50        37.50
## 4   4  1      8 25.00        25.00
## 2   6  0      4 12.50        12.50
## 1   4  0      3  9.38         9.38
## 5   6  1      3  9.38         9.38
## 6   8  1      2  6.25         6.25
Metadata

Version

0.2.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • 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