View source: R/plot_multibars.R
plot_multibars | R Documentation |
Create a multiple custom bar plots. With purr::map you can create a list of barplots.
plot_multibars(data, row = 1:nrow(data), labels = waiver())
data |
dataframe |
row |
select which row to plot. Default: 1:nrow(.) |
labels |
select labels. Default: waiver() |
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.