knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

tidytab

Create tidyverse-friendly tables of frequencies

R-CMD-check Codecov test coverage CRAN status R-universe status Lifecycle: experimental

Installation

You can install tidytab from GitHub with:

# install.packages("devtools")
devtools::install_github("gvelasq/tidytab")

Usage

library(tidytab)

# one-way table of frequencies
mtcars |> tab(cyl)

# two-way table of frequencies (a special 2x2 contingency table)
mtcars |> tab(cyl, gear)

# flat contingency tables of three (or more) variables
mtcars |> tab(cyl, gear, am)

# tables wider than the R console are automatically wrapped
mtcars |> tab(cyl, gear, am, vs)

# missing values are displayed in red
tab(letters[24:27])

# ftab() displays only flat contingency tables (here, with two variables)
mtcars |> ftab(cyl, gear)

# tab1() displays one-way tables for each variable
mtcars |> tab1(cyl, gear)

# tab2() displays two-way tables for all variable combinations
mtcars |> tab2(cyl, gear, am)

# ta() is a shortened alias for tab(), inspired by Stata
mtcars |> ta(gear)

Code of Conduct

Please note that the tidytab project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.



gvelasq-r/tabr documentation built on May 1, 2024, 12:12 a.m.