Learn R Programming

radiant.data (version 0.6.0)

pivotr: Create a pivot table using dplyr

Description

Create a pivot table using dplyr

Usage

pivotr(dataset, cvars = "", nvar = "None", fun = "mean_rm", normalize = "None", tabfilt = "", tabsort = "", nr = NULL, data_filter = "", shiny = FALSE)

Arguments

dataset
Name of the dataframe to change
cvars
Categorical variables
nvar
Numerical variable
fun
Function to apply to numerical variable
normalize
Normalize the table by "row" total,"column" totals, or overall "total"
tabfilt
Expression used to filter the table. This should be a string (e.g., "Total > 10000")
tabsort
Expression used to sort the table (e.g., "-Total")
nr
Number of rows to display
data_filter
Expression used to filter the dataset. This should be a string (e.g., "price > 10000")
shiny
Logical (TRUE, FALSE) to indicate if the function call originate inside a shiny app

Details

Create a pivot-table. See http://radiant-rstats.github.io/docs/data/pivotr.html for an example in Radiant

Examples

Run this code
result <- pivotr("diamonds", cvars = "cut")$tab
result <- pivotr("diamonds", cvars = c("cut","clarity","color"))$tab
result <- pivotr("diamonds", cvars = "cut:clarity", nvar = "price")$tab
result <- pivotr("diamonds", cvars = "cut", nvar = "price")$tab
result <- pivotr("diamonds", cvars = "cut", normalize = "total")$tab

Run the code above in your browser using DataLab