plot_multibars: Multiple custom bar plots

View source: R/plot_multibars.R

plot_multibarsR Documentation

Multiple custom bar plots

Description

Create a multiple custom bar plots. With purr::map you can create a list of barplots.

Usage

plot_multibars(data, row = 1:nrow(data), labels = waiver())

Arguments

data

dataframe

row

select which row to plot. Default: 1:nrow(.)

labels

select labels. Default: waiver()

Examples

# Plot multiple bar plots to same grid
library(gridExtra)

plot_basic <- mtcars %>%
  dplyr::group_by(cyl) %>%
  dplyr::summarise_at(dplyr::vars(mpg, disp, hp, wt), ~mean(.)) %>%
  tidyr::gather(2:ncol(.), key = "question", value = "values") %>%
  tidyr::spread(cyl, values) %>%
  {purrr::map(list(1, 2, 3), function(x) plot_multibars(., x))}
do.call("grid.arrange", c(plot_basic, ncol = 2))

# Plot a single bar plot
plot_multibars(mtcars, row = 3)

JouniVatanen/stools documentation built on Jan. 25, 2023, 8:49 p.m.