knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

tabulR

Linux/OSX Windows Coverage

tabulR serves two purposes, to generate "quick" tables using qtable() and plots using line_chart() and bar_chart().

Note: This is a work in progress.

Installation

Development version:

devtools::install_github("itsdalmo/tabulR")

CRAN:

# Not on CRAN yet.

Usage

qtable takes one or more variables and returns a table (made with data.table) depending on type:

qtable (and charts by extension) always does the following:

bar_chart and line_chart also:

require(tabulR)
set.seed(100L)
df <- data.frame(
  group = factor(rbinom(100, 4, .2), labels = paste("Group", LETTERS[1:4])),
  fct = factor(rbinom(100, 2, .3), labels = c("Yes", "No", "Don't know")),
  dum = factor(rbinom(100, 1, .5), labels = c("Answer A", "Answer B")),
  num1 = runif(100, 0, 100),
  num2 = runif(100, 0, 100),
  stringsAsFactors = FALSE
)

Numeric

qtable_(df, vars = "num1", groups = c("group", "fct"))

Factor

qtable_(df, vars = "fct", groups = "group")

Chart

bar_chart_(df, vars = "num1", groups = "group")

NSE

qtable is not exactly a NSE version (non standard evaluation) of qtable_, it also requires dplyr to use. It expects unquoted arguments for vars, and supports one_of(), starts_with() etc. from dplyr. The same is true for the charts, such as bar_chart and bar_chart_.

Table

require(dplyr)
df %>% group_by(group) %>% qtable(starts_with("num"))

Chart

df %>% group_by(group) %>% bar_chart(starts_with("num"), margin = FALSE)


itsdalmo/tabulR documentation built on May 18, 2019, 7:11 a.m.