simple_pivot: Simple Pivot Data Transformation

Description Usage Arguments Value Examples

View source: R/simple_pivot.R

Description

Simple Pivot Data Transformation

Usage

1
simple_pivot(df, row_vars, col_vars, value_variable, value_function)

Arguments

df

Data frame object to transform

row_vars

Character vector naming the row variable(s)

col_vars

Character vector naming the column variable(s)

value_variable

Length 1 character vector naming the column with the value to summarise in table cells

value_function

Function that takes a single vector of values as first (and only required) argument and returns a single summary value (the base r 'mean' function, for example). Used to summarise the 'value variable' (by row/column group).

Value

a tibble/data.frame with the pivot operation applied to it

Examples

1
2
3
4
5
simple_pivot(df = mtcars,
 row_vars = c("gear"),
 col_vars = c("carb"),
 value_variable = "mpg",
 value_function = sum)

ltdroy/simplepivot documentation built on Aug. 8, 2020, 9:41 a.m.