Add a bar plot to a chronicle report
add_barplot(
report = "",
dt,
bars,
value = NULL,
break_bars_by = NULL,
horizontal = FALSE,
sort_by_value = FALSE,
sort_decreasing = TRUE,
ggtheme = "minimal",
x_axis_label = NULL,
y_axis_label = NULL,
plot_palette = NULL,
plot_palette_generator = NULL,
barplot_title = NULL,
title_level = 2,
echo = FALSE,
message = FALSE,
warning = FALSE,
fig_width = NULL,
fig_height = NULL
)
Character string containing the text of an Rmarkdown report header (and possibly more chunks). Easily create one with chronicle::new_report(), and if NULL, that will be the default value.
Table with the data for the plot.
Name of the columns containing the different groups.
Name of the columns to use as values on the y axis of the plot. If NULL (default), counts will be used.
Name of the categorical variable used to break each bar
Plot the bars horizontally. Default is FALSE
Sort the bars by value. Default is FALSE
Sort the values decreasingly. Default is TRUE, but sort_by_value must also be TRUE.
ggplot2 theme function to apply. Default is ggplot2::theme_minimal.
Label for the x axis.
Label for the y axis.
Character vector of hex codes specifying the colors to use on the plot.
Palette from the viridis package used in case plot_palette is unspecified or insufficient for the number of colors required.
Title of the bar plot section on the report. If NULL, chronicle will try to parse a generic title using make_title()
Level of the section title of this plot (ie, number of # on Rmarkdown syntax.)
Whether to display the source code in the output document. Default is FALSE.
Whether to preserve messages on rendering. Default is FALSE.
Whether to preserve warnings on rendering. Default is FALSE.
Width of the plot (in inches).
Height of the plot (in inches).
An rmarkdown file as a character string, now containing a chunk for adding the specified bar plot.
# NOT RUN {
html_report <- add_barplot(report = '',
dt = iris,
bars = 'Species',
value = 'Sepal.Length')
cat(html_report)
# }
Run the code above in your browser using DataLab