slice_top_categories: Slice a dataframe to include only the top categories

View source: R/slice-dice.R

slice_top_categoriesR Documentation

Slice a dataframe to include only the top categories

Description

This slices a dataframe to only include the most frequent

Usage

slice_top_categories(.data, .n, ..., .wt = NULL)

Arguments

.data

a dataframe

.n

the number of categories to include

...

columns which define categories

.wt

an optional weight category

Value

A dataframe containing only the top categories

Examples

# give the top 1 most occuring value of `cyl`
slice_top_categories(mtcars, 1, cyl)

# give the top 1 most occuring value of `cyl` weighted by am
slice_top_categories(mtcars, 1, cyl, .wt = am)

# give the 2 most occuring values of (cyl, gear) pair
slice_top_categories(mtcars, 2, cyl, gear)

colin-fraser/colinlib documentation built on Nov. 30, 2022, 11:10 p.m.