Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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

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

radiant.data

Data Menu for Radiant: Business Analytics using R and Shiny

v1.3.12
AGPL-3 | file LICENSE
Authors
Vincent Nijs [aut, cre]
Initial release
2020-11-25

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.