size_order: Make an ordered factor with most important level first

View source: R/size_order.R

size_orderR Documentation

Make an ordered factor with most important level first

Description

Useful when making bar plots and have the most common level in the bottom. Also possible to remove uncommon levels and create new level called other.

Usage

size_order(x, other_count = NULL, other_level = "Övriga")

Arguments

x

Vector

other_count

How many levels should be considered as other level

other_level

What the new level should be called

Examples

table(ggplot2::diamonds$cut)
in_size_order <- size_order(ggplot2::diamonds$cut)
table(in_size_order)
in_size_order <- size_order(ggplot2::diamonds$cut, 2, "Others")
table(in_size_order)

swehip/shprplotfun documentation built on Oct. 21, 2022, 8:26 a.m.