Learn R Programming

radiant.data (version 1.4.5)

pivotr: Create a pivot table

Description

Create a pivot table

Usage

pivotr(
  dataset,
  cvars = "",
  nvar = "None",
  fun = "mean",
  normalize = "None",
  tabfilt = "",
  tabsort = "",
  nr = Inf,
  data_filter = "",
  envir = parent.frame()
)

Arguments

dataset

Dataset to tabulate

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 (e.g., "Total > 10000")

tabsort

Expression used to sort the table (e.g., "desc(Total)")

nr

Number of rows to display

data_filter

Expression used to filter the dataset before creating the table (e.g., "price > 10000")

envir

Environment to extract data from

Details

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

Examples

Run this code
pivotr(diamonds, cvars = "cut") %>% str()
pivotr(diamonds, cvars = "cut")$tab
pivotr(diamonds, cvars = c("cut","clarity","color"))$tab
pivotr(diamonds, cvars = "cut:clarity", nvar = "price")$tab
pivotr(diamonds, cvars = "cut", nvar = "price")$tab
pivotr(diamonds, cvars = "cut", normalize = "total")$tab

Run the code above in your browser using DataLab