plot_order_set: plot_order_set

View source: R/plot_order_set.R

plot_order_setR Documentation

plot_order_set

Description

Sets order for a ggplot using a column and a vector

Usage

plot_order_set(df, Column, Order)

Arguments

df

tidy data frame to be ordered

Column

which column to be ordered.

Order

Vector to order by.

Value

Orders ggplot

Examples

library(tidyverse);library(lubridate)
dfplot <- fmxdat::SectorTRIs %>% gather(type, val, -Date)
ord <- rev(unique(dfplot$type))
dfplot %>% ggplot() + geom_line(aes(Date, val, color = type))
# Reordered now:
dfplot %>% plot_order_set( Column = "type", Order = ord) %>% ggplot() + geom_line(aes(Date, val, color = type))

Nicktz/fmxdat documentation built on Aug. 25, 2024, 10:18 a.m.