knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
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.
Development version:
devtools::install_github("itsdalmo/tabulR")
CRAN:
# Not on CRAN yet.
qtable
takes one or more variables and returns a table (made with data.table) depending on type:
numeric
: The count and weighted mean.factor
/character
: Count and weighted proportions.date
(including POSIX): Count and Min/Max dates. qtable
(and charts by extension) always does the following:
0
, 0
and NA
respectively.groups
).bar_chart
and line_chart
also:
geom_text()
.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 )
qtable_(df, vars = "num1", groups = c("group", "fct"))
qtable_(df, vars = "fct", groups = "group")
bar_chart_(df, vars = "num1", groups = "group")
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_
.
require(dplyr) df %>% group_by(group) %>% qtable(starts_with("num"))
df %>% group_by(group) %>% bar_chart(starts_with("num"), margin = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.