add_histogram {chronicle}R Documentation

Add a histogram plot to a chronicle report

Description

Add a histogram plot to a chronicle report

Usage

add_histogram(
  report = "",
  dt,
  value,
  groups = NULL,
  binwidth = NULL,
  bins = NULL,
  scales = "fixed",
  ggtheme = NULL,
  x_axis_label = NULL,
  plot_palette = NULL,
  plot_palette_generator = NULL,
  histogram_title = NULL,
  title_level = 2,
  echo = FALSE,
  message = FALSE,
  warning = FALSE,
  fig_width = NULL,
  fig_height = NULL
)

Arguments

report

Character string containing all the R Markdown chunks previously added. Default is ”, an empty report.

dt

data.frame containing the data to plot.

value

Name of the column to use as values on the y axis of the plot.

groups

Name of the column containing the different groups.

binwidth

Width of the histogram bins.

bins

Number of bins. Overridden by binwidth. Defaults to 30.

scales

From ggplot2::facet_wrap: Should scales be 'fixed', 'free', or free in one dimension ('free_x', 'free_y'). Default is 'fixed'.

ggtheme

ggplot2 theme function to apply. Default is ggplot2::theme_minimal.

x_axis_label

Label for the x axis.

plot_palette

Character vector of hex codes specifying the colors to use on the plot.

plot_palette_generator

Palette from the viridis package used in case plot_palette is unspecified or insufficient for the number of colors required.

histogram_title

Title of the histogram plot section on the report. If NULL, chronicle will try to parse a generic title using make_title()

title_level

Level of the section title of this plot (ie, number of # on Rmarkdown syntax.)

echo

Whether to display the source code in the output document. Default is FALSE.

message

Whether to preserve messages on rendering. Default is FALSE.

warning

Whether to preserve warnings on rendering. Default is FALSE.

fig_width

Width of the plot (in inches).

fig_height

Height of the plot (in inches).

Value

An rmarkdown chunk as a character string, now containing a chunk for adding the histogram plot.

Examples

html_report <- add_histogram(report = "",
                             dt = iris,
                             value = 'Sepal.Length',
                             groups = 'Species')
cat(html_report)

[Package chronicle version 0.3 Index]