Title: | Grammar for Creating R Markdown Reports |
---|---|
Description: | A system for creating R Markdown reports with a sequential syntax. |
Authors: | Philippe Heymans Smith [aut, cre] |
Maintainer: | Philippe Heymans Smith <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.3 |
Built: | 2024-10-11 04:16:21 UTC |
Source: | https://github.com/pheymanss/chronicle |
Add a bar plot to a chronicle report
add_barplot( report = "", dt, bars, value = NULL, break_bars_by = NULL, up_to_n_bars = 20, 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 )
add_barplot( report = "", dt, bars, value = NULL, break_bars_by = NULL, up_to_n_bars = 20, 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 )
report |
Character string containing all the R Markdown chunks previously added. Default is ”, an empty report. |
dt |
Table with the data for the plot. |
bars |
Name of the columns containing the different groups. |
value |
Name of the columns to use as values on the y axis of the plot. If NULL (default), counts will be used. |
break_bars_by |
Name of the categorical variable used to break each bar |
up_to_n_bars |
Plot up to this number of bars. If there are more distinct values in 'bars', the function will summarise them into an 'Others' category. Default is 20 |
horizontal |
Plot the bars horizontally. Default is FALSE. |
sort_by_value |
Sort the bars by value. Default is FALSE. |
sort_decreasing |
Sort the values decreasingly. Default is TRUE, but sort_by_value must also be TRUE. |
ggtheme |
ggplot2 theme function to apply. Default is ggplot2::theme_minimal. |
x_axis_label |
Label for the x axis. |
y_axis_label |
Label for the y 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. |
barplot_title |
Title of the bar 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). |
An rmarkdown file as a character string, now containing a chunk for adding the specified bar plot.
html_report <- add_barplot(report = '', dt = iris, bars = 'Species', value = 'Sepal.Length') cat(html_report)
html_report <- add_barplot(report = '', dt = iris, bars = 'Species', value = 'Sepal.Length') cat(html_report)
Add a box plot to a chronicle report
add_boxplot( report = "", dt, value, groups = NULL, split_groups_by = NULL, jitter = TRUE, ggtheme = NULL, x_axis_label = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = NULL, boxplot_title = NULL, title_level = 2, echo = FALSE, message = FALSE, warning = FALSE, fig_width = NULL, fig_height = NULL )
add_boxplot( report = "", dt, value, groups = NULL, split_groups_by = NULL, jitter = TRUE, ggtheme = NULL, x_axis_label = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = NULL, boxplot_title = NULL, title_level = 2, echo = FALSE, message = FALSE, warning = FALSE, fig_width = NULL, fig_height = NULL )
report |
Character string containing all the R Markdown chunks previously added. Default is ”, an empty report. |
dt |
Table with the data for the 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. |
split_groups_by |
Column to split each group. |
jitter |
Whether to add the actual values of each observation over the box plots. Only done when dt has 1000 rows or less. |
ggtheme |
ggplot2 theme function to apply. Default is ggplot2::theme_minimal. |
x_axis_label |
Label for the x axis. |
y_axis_label |
Label for the y 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. |
boxplot_title |
Title of the box 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). |
An rmarkdown file as a character string, now containing a chunk for adding the specified box plot.
html_report <- add_boxplot(report = '', dt = iris, value = 'Sepal.Length', groups = 'Species', jitter = TRUE) cat(html_report)
html_report <- add_boxplot(report = '', dt = iris, value = 'Sepal.Length', groups = 'Species', jitter = TRUE) cat(html_report)
Transforms a function call into an Rmarkdown chunk
add_chunk( report = "", fun, params, chunk_title = NULL, title_level = 2, echo = FALSE, message = FALSE, warning = FALSE, fig_width = NULL, fig_height = NULL, guess_title = TRUE )
add_chunk( report = "", fun, params, chunk_title = NULL, title_level = 2, echo = FALSE, message = FALSE, warning = FALSE, fig_width = NULL, fig_height = NULL, guess_title = TRUE )
report |
Character string containing all the R Markdown chunks previously added. Default is ”, an empty report. |
fun |
Function to call. |
params |
List of parameters to be passed to fun. |
chunk_title |
Title of the Rmarkdown chunk. If NULL, chronicle will try to parse a generic title based on the function and parameters passed 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). |
guess_title |
If TRUE, tries to generate a generic title for chronicle::make_* family of functions (eg 'Sepal.Length vs Sepal.Width by Species' for make_scatter) |
An rmarkdown chunk as a character string.
library(chronicle) html_chunk <- add_chunk(fun = chronicle::make_barplot, params = list(dt = 'iris', value = 'Sepal.Width', bars = 'Species')) cat(html_chunk)
library(chronicle) html_chunk <- add_chunk(fun = chronicle::make_barplot, params = list(dt = 'iris', value = 'Sepal.Width', bars = 'Species')) cat(html_chunk)
Beware that code indentation of the chronicle call will affect the indentation of the chunk, so make sure not to leave unintended indentation in the 'code' parameter on this function call.
add_code( report = "", code, code_title = NULL, title_level = 2, eval = TRUE, echo = TRUE, message = FALSE, warning = FALSE, fig_width = NULL, fig_height = NULL )
add_code( report = "", code, code_title = NULL, title_level = 2, eval = TRUE, echo = TRUE, message = FALSE, warning = FALSE, fig_width = NULL, fig_height = NULL )
report |
Character string containing all the R Markdown chunks previously added. Default is ”, an empty report. |
code |
The code that will be added to the report. Mind the indentation on the call, since spaces between quotations will be preserved. |
code_title |
The title of the text section. Default is NULL. |
title_level |
Level of the section title of this text (ie, number of # on Rmarkdown syntax.) |
eval |
Run the code instead of just display it. Default is TRUE. |
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 figures printed from this code. |
fig_height |
Height of the figures printed from this code. |
The text of the Rmarkdown report plus an additional section with the code chunk.
html_report <- add_code(report = '', code_title = 'Code comes after this title', code = 'f <- function(x, y){paste(x,y)}, f("a", "b")', eval = FALSE, echo = TRUE, fig_width = 12, fig_height = 8) cat(html_report)
html_report <- add_code(report = '', code_title = 'Code comes after this title', code = 'f <- function(x, y){paste(x,y)}, f("a", "b")', eval = FALSE, echo = TRUE, fig_width = 12, fig_height = 8) cat(html_report)
Add a density plot to a chronicle report
add_density( report = "", dt, value, groups = NULL, faceted = TRUE, scales = "fixed", ggtheme = NULL, x_axis_label = NULL, plot_palette = NULL, plot_palette_generator = NULL, density_title = NULL, title_level = 2, echo = FALSE, message = FALSE, warning = FALSE, fig_width = NULL, fig_height = NULL )
add_density( report = "", dt, value, groups = NULL, faceted = TRUE, scales = "fixed", ggtheme = NULL, x_axis_label = NULL, plot_palette = NULL, plot_palette_generator = NULL, density_title = NULL, title_level = 2, echo = FALSE, message = FALSE, warning = FALSE, fig_width = NULL, fig_height = NULL )
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. |
faceted |
If TRUE (default), each group will be plotted separately. |
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. |
density_title |
Title of the density 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). |
An rmarkdown file as a character string, now containing a chunk for adding the specified density plot.
html_report <- add_density(report = "", dt = iris, value = 'Sepal.Length', groups = 'Species') cat(html_report)
html_report <- add_density(report = "", dt = iris, value = 'Sepal.Length', groups = 'Species') cat(html_report)
Add a dygraph to a chronicle report
add_dygraph( report = "", dt, value, date, groups = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = NULL, dygraph_title = NULL, title_level = 2, echo = FALSE, message = FALSE, warning = FALSE, fig_width = NULL, fig_height = NULL )
add_dygraph( report = "", dt, value, date, groups = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = NULL, dygraph_title = NULL, title_level = 2, echo = FALSE, message = FALSE, warning = FALSE, fig_width = NULL, fig_height = NULL )
report |
Character string containing all the R Markdown chunks previously added. Default is ”, an empty report. |
dt |
Data to plot |
value |
Name of the column of the data frame containing the numerical variables of the time series. |
date |
Name of the column containing the date variable. It must be already a date or time object. |
groups |
Name of the columns containing the different groups. |
y_axis_label |
Label for the y axis. x axis is the date (or time) so it is not needed |
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. |
dygraph_title |
Title for the Rmarkdown section containing the dygraph |
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). |
An R Markdown file as a character string, now containing a chunk for the specified dygraph.
dat <- data.frame(x = c(rnorm(100, 2, 4), rnorm(100, 6, 1), rnorm(100, 8, 2)), group = c(rep('A', 100), rep('B', 100), rep('C', 100)), date = rep(seq(as.Date("2020-01-01"), as.Date("2020-04-09"), 'days'), 3)) html_report <- add_dygraph(report = '', dt = dat, value = 'x', date = 'date') cat(html_report)
dat <- data.frame(x = c(rnorm(100, 2, 4), rnorm(100, 6, 1), rnorm(100, 8, 2)), group = c(rep('A', 100), rep('B', 100), rep('C', 100)), date = rep(seq(as.Date("2020-01-01"), as.Date("2020-04-09"), 'days'), 3)) html_report <- add_dygraph(report = '', dt = dat, value = 'x', date = 'date') cat(html_report)
Add a histogram plot to a chronicle report
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 )
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 )
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). |
An rmarkdown chunk as a character string, now containing a chunk for adding the histogram plot.
html_report <- add_histogram(report = "", dt = iris, value = 'Sepal.Length', groups = 'Species') cat(html_report)
html_report <- add_histogram(report = "", dt = iris, value = 'Sepal.Length', groups = 'Species') cat(html_report)
Add an image to a chronicle Rmarkdown report
add_image( report = "", image_path, image_caption = NULL, image_title = NULL, title_level = 2, fig_width = NULL, fig_height = NULL )
add_image( report = "", image_path, image_caption = NULL, image_title = NULL, title_level = 2, fig_width = NULL, fig_height = NULL )
report |
Character string containing all the R Markdown chunks previously added. Default is ”, an empty report. |
image_path |
The path to the image that will be added to the report. |
image_caption |
A caption to be printed for the image. |
image_title |
The title of the text section. Default is NULL. |
title_level |
Level of the section title of this text (ie, number of # on Rmarkdown syntax.) |
fig_width |
Width of the figures printed from this code. |
fig_height |
Height of the figures printed from this code. |
The text of the Rmarkdown report plus an additional section with the text.
library(chronicle) report <- add_image(image_path = 'readme1.png', image_caption = 'This is the caption of the image', image_title = 'This is the image that I want to include')
library(chronicle) report <- add_image(image_path = 'readme1.png', image_caption = 'This is the caption of the image', image_title = 'This is the image that I want to include')
Add a line plot to a chronicle report
add_lineplot( report = "", dt, x, y, groups = NULL, faceted = NULL, scales = NULL, show_trend = NULL, trend_method = NULL, ggtheme = NULL, x_axis_label = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = NULL, lineplot_title = NULL, title_level = 2, echo = FALSE, message = FALSE, warning = FALSE, fig_width = NULL, fig_height = NULL )
add_lineplot( report = "", dt, x, y, groups = NULL, faceted = NULL, scales = NULL, show_trend = NULL, trend_method = NULL, ggtheme = NULL, x_axis_label = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = NULL, lineplot_title = NULL, title_level = 2, echo = FALSE, message = FALSE, warning = FALSE, fig_width = NULL, fig_height = NULL )
report |
Character string containing all the R Markdown chunks previously added. Default is ”, an empty report. |
dt |
data.frame containing the data to plot. |
x |
Value on the x axis. |
y |
Value on the y axis. |
groups |
Name of the column containing the different groups. |
faceted |
If TRUE (default), each group will be plotted separately. |
scales |
From ggplot2::facet_wrap: Should scales be 'fixed', 'free', or free in one dimension ('free_x', 'free_y'). Default is 'fixed'. |
show_trend |
If TRUE, adds a ggplot2::geom_smooth() line to the plot. |
trend_method |
The method ggplot2::geom_smooth will use. Default is 'loess', which is a local polynomial regression fit |
ggtheme |
ggplot2 theme function to apply. Default is ggplot2::theme_minimal. |
x_axis_label |
Label for the x axis. |
y_axis_label |
Label for the y 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. |
lineplot_title |
Title of the line 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). |
An R Markdown file as a character string, now containing a chunk for the specified line plot.
html_report <- add_lineplot(report = "", dt = ggplot2::mpg, x = 'hwy', y = 'cty', groups = 'manufacturer', faceted = FALSE) cat(html_report)
html_report <- add_lineplot(report = "", dt = ggplot2::mpg, x = 'hwy', y = 'cty', groups = 'manufacturer', faceted = FALSE) cat(html_report)
This is useful when assembling functions calls, where you specify parameter names and character values at the same time.
add_quotes(x, except = NULL, single_quote = TRUE, collapse = NULL)
add_quotes(x, except = NULL, single_quote = TRUE, collapse = NULL)
x |
List or named vector |
except |
Vector specifying the names of the elements that should not be enquoted. |
single_quote |
Use single quotes (') instead of double quotes ("). Default is TRUE. |
collapse |
If not NULL, collapse the values into a single vector using this value as the separator. Default is NULL. |
The list or named vector, with additional quotes around the appropriate values
params = list(a = TRUE, b = FALSE, c = 'ABC', d = 15) add_quotes(params) add_quotes(params, except = 'c')
params = list(a = TRUE, b = FALSE, c = 'ABC', d = 15) add_quotes(params) add_quotes(params, except = 'c')
Add a raincloud plot to a chronicle report
add_raincloud( report = "", dt, value, groups = NULL, adjust = 0.5, include_boxplot = TRUE, include_mean = FALSE, include_median = TRUE, force_all_jitter_obs = FALSE, ggtheme = "minimal", x_axis_label = NULL, plot_palette = NULL, plot_palette_generator = NULL, static = NULL, raincloud_title = NULL, title_level = 2, echo = FALSE, message = FALSE, warning = FALSE, fig_width = NULL, fig_height = NULL )
add_raincloud( report = "", dt, value, groups = NULL, adjust = 0.5, include_boxplot = TRUE, include_mean = FALSE, include_median = TRUE, force_all_jitter_obs = FALSE, ggtheme = "minimal", x_axis_label = NULL, plot_palette = NULL, plot_palette_generator = NULL, static = NULL, raincloud_title = NULL, title_level = 2, echo = FALSE, message = FALSE, warning = FALSE, fig_width = NULL, fig_height = NULL )
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. |
adjust |
Width of the kernel bins. The smaller the value, the higher the resolution of the density. For full details, see ?ggplot2::stat_density. |
include_boxplot |
Include a boxplot over the raincloud. Default is TRUE. |
include_mean |
Mark the median of each distribution. Default is TRUE. |
include_median |
Mark the mean of each distribution. Default is FALSE. |
force_all_jitter_obs |
When the data has more than 1000 observations, the function will sample 1000 observations in order to keep the object reasonably small. If you need to override it, set this value to TRUE. |
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. |
static |
If TRUE, the output will be static ggplot chart instead of an interactive ggplotly chart. Default is FALSE. |
raincloud_title |
Title of the raincloud 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). |
An rmarkdown file as a character string, now containing a chunk for adding the specified raincloud plot.
html_report <- add_raincloud(report = "", dt = iris, value = 'Sepal.Length', groups = 'Species') cat(html_report)
html_report <- add_raincloud(report = "", dt = iris, value = 'Sepal.Length', groups = 'Species') cat(html_report)
Add a scatter plot to a chronicle report
add_scatterplot( report = "", dt, x, y, groups = NULL, faceted = NULL, scales = NULL, show_trend = NULL, trend_method = NULL, ggtheme = NULL, x_axis_label = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = NULL, scatterplot_title = NULL, title_level = 2, echo = FALSE, message = FALSE, warning = FALSE, fig_width = NULL, fig_height = NULL )
add_scatterplot( report = "", dt, x, y, groups = NULL, faceted = NULL, scales = NULL, show_trend = NULL, trend_method = NULL, ggtheme = NULL, x_axis_label = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = NULL, scatterplot_title = NULL, title_level = 2, echo = FALSE, message = FALSE, warning = FALSE, fig_width = NULL, fig_height = NULL )
report |
Character string containing all the R Markdown chunks previously added. Default is ”, an empty report. |
dt |
data.frame containing the data to plot. |
x |
Value on the x axis. |
y |
Value on the y axis. |
groups |
Name of the column containing the different groups. |
faceted |
If TRUE (default), each group will be plotted separately. |
scales |
From ggplot2::facet_wrap: Should scales be 'fixed', 'free', or free in one dimension ('free_x', 'free_y'). Default is 'fixed'. |
show_trend |
If TRUE, adds a ggplot2::geom_smooth() line to the plot. Default is FALSE. |
trend_method |
The method ggplot2::geom_smooth will use. Default is 'loess', which is a local polynomial regression fit |
ggtheme |
ggplot2 theme function to apply. Default is ggplot2::theme_minimal. |
x_axis_label |
Label for the x axis. |
y_axis_label |
Label for the y 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. |
scatterplot_title |
Title of the scatter 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). |
An R Markdown file as a character string, now containing a chunk for the specified scatter plot.
html_report <- add_scatterplot(report = "", dt = ggplot2::mpg, x = 'hwy', y = 'cty', groups = 'manufacturer', faceted = FALSE) cat(html_report)
html_report <- add_scatterplot(report = "", dt = ggplot2::mpg, x = 'hwy', y = 'cty', groups = 'manufacturer', faceted = FALSE) cat(html_report)
Add a table to a chronicle report
add_table( report = "", table, table_title = NULL, title_level = 2, html_table_type = c("DT", "kable"), table_params = NULL, fig_width = NULL, fig_height = NULL )
add_table( report = "", table, table_title = NULL, title_level = 2, html_table_type = c("DT", "kable"), table_params = NULL, fig_width = NULL, fig_height = NULL )
report |
Character string containing all the R Markdown chunks previously added. Default is ”, an empty report. |
table |
data.frame to print on the report. |
table_title |
title of the table. Default is no title. |
title_level |
Level of the section title of this plot (ie, number of # on Rmarkdown syntax.) |
html_table_type |
Either print a knitr::kable table or a DT htmlwidget. |
table_params |
A named list of additional parameters to be passed to either knitr::kable() or DT::datatable(), depending on html_table_type |
fig_width |
Width of the figures printed from this code. |
fig_height |
Height of the figures printed from this code. |
An R Markdown file as a character string, now containing a chunk for the specified table.
html_report <- add_table(table = iris, table_title = 'Iris measures', html_table_type = 'kable') cat(html_report)
html_report <- add_table(table = iris, table_title = 'Iris measures', html_table_type = 'kable') cat(html_report)
Add text to a chronicle Rmarkdown report
add_text(report = "", text, text_title = NULL, title_level = 2)
add_text(report = "", text, text_title = NULL, title_level = 2)
report |
Character string containing all the R Markdown chunks previously added. Default is ”, an empty report. |
text |
The text that will be added to the report. |
text_title |
The title of the text section. Default is NULL. |
title_level |
Level of the section title of this text (ie, number of # on Rmarkdown syntax.) Default is 1. |
The text of the Rmarkdown report plus an additional section with the text.
html_report <- add_text(text = 'This is the text that will be seen outside of any chunk', text_title = 'Text title') cat(html_report)
html_report <- add_text(text = 'This is the text that will be seen outside of any chunk', text_title = 'Text title') cat(html_report)
Add a titled section to a chronicle Rmarkdown report
add_title(report = "", title, title_level = 1)
add_title(report = "", title, title_level = 1)
report |
Character string containing all the R Markdown chunks previously added. Default is ”, an empty report. |
title |
The title to be added as a section. |
title_level |
Level of the section title (ie, number of # on Rmarkdown syntax.) |
The text of the Rmarkdown report plus an additional section by the given title.
html_report <- add_title(report = '', title = 'Just the title here') cat(html_report)
html_report <- add_title(report = '', title = 'Just the title here') cat(html_report)
Add a violin plot to a chronicle report
add_violin( report = "", dt, value, groups = NULL, jitter = NULL, ggtheme = NULL, x_axis_label = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = NULL, violin_title = NULL, title_level = 2, echo = FALSE, message = FALSE, warning = FALSE, fig_width = NULL, fig_height = NULL )
add_violin( report = "", dt, value, groups = NULL, jitter = NULL, ggtheme = NULL, x_axis_label = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = NULL, violin_title = NULL, title_level = 2, echo = FALSE, message = FALSE, warning = FALSE, fig_width = NULL, fig_height = NULL )
report |
Character string containing all the R Markdown chunks previously added. Default is ”, an empty report. |
dt |
Table with the data for the 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. |
jitter |
Whether to add the actual values of each observation over the violin plots. Only done when dt has 1000 rows or less. |
ggtheme |
ggplot2 theme function to apply. Default is ggplot2::theme_minimal. |
x_axis_label |
Label for the x axis. |
y_axis_label |
Label for the y 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. |
violin_title |
Title of the violin 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). |
An rmarkdown chunk as a character string, now containing a chunk for adding the violin plot.
html_report <- add_violin(report = "", dt = iris, value = 'Sepal.Length', groups = 'Species', jitter = TRUE) cat(html_report)
html_report <- add_violin(report = "", dt = iris, value = 'Sepal.Length', groups = 'Species', jitter = TRUE) cat(html_report)
Assembles a formatted function call from a function and a list of parameters
assemble_call(fun_name, params, non_char = NULL)
assemble_call(fun_name, params, non_char = NULL)
fun_name |
Name of the function to be called (must be a character or coercible to a character). |
params |
Named list or vector containing the parameters for the fun call. |
non_char |
Names of the parameters whose values should not be interpreted as character values |
A character string with the formatted function call.
chronicle::assemble_call(fun_name = 'base::sapply', params = list(X = 'iris', FUN= 'class')) chronicle::assemble_call(fun_name = 'base::sapply', params = list(X = 'iris', FUN= 'class'), non_char = c('X', 'FUN'))
chronicle::assemble_call(fun_name = 'base::sapply', params = list(X = 'iris', FUN= 'class')) chronicle::assemble_call(fun_name = 'base::sapply', params = list(X = 'iris', FUN= 'class'), non_char = c('X', 'FUN'))
Warns if any of the passed column names is missing from the data provided.
check_cols(dt, cols)
check_cols(dt, cols)
dt |
A data.frame. |
cols |
A vector of column names. |
The vector of all columns present in dt.
chronicle::check_cols(mtcars, c('cyl', 'made_up_column'))
chronicle::check_cols(mtcars, c('cyl', 'made_up_column'))
Currently supports:
file_extension(file_type)
file_extension(file_type)
file_type |
R Markdown output formats. |
* rmdformats * prettydoc * bookdown * ioslides * tufte_html * xaringan * rolldown * flexdashboard * slidy_presentation * html_document * html_notebook * pagedown
The file extension corresponding to the provided formats (".html", "pdf", ".md", ".docx", ".pptx")
file_extension(c('prettydoc', 'word_document', 'tufte_handout'))
file_extension(c('prettydoc', 'word_document', 'tufte_handout'))
Create a bar plot from a data frame through ggplotly
make_barplot( dt, bars, value = NULL, break_bars_by = NULL, up_to_n_bars = 20, horizontal = FALSE, sort_by_value = horizontal, sort_decreasing = TRUE, ggtheme = "minimal", x_axis_label = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = "plasma", static = FALSE )
make_barplot( dt, bars, value = NULL, break_bars_by = NULL, up_to_n_bars = 20, horizontal = FALSE, sort_by_value = horizontal, sort_decreasing = TRUE, ggtheme = "minimal", x_axis_label = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = "plasma", static = FALSE )
dt |
data.frame containing the data to plot. |
bars |
Name of the column containing the different groups. |
value |
Name of the columns to use as value on the y axis of the plot. If NULL (default), counts will be used. |
break_bars_by |
Name of the categorical variable used to break each bar |
up_to_n_bars |
Plot up to this number of bars. If there are more distinct values in 'bars', the function will summarise them into an 'Others' category. Default is 20. |
horizontal |
Plot the bars horizontally. Default is FALSE. |
sort_by_value |
Sort the bars by value. Default is FALSE unless horizontal is TRUE. |
sort_decreasing |
Sort the values decreasingly. Default is TRUE, but sort_by_value must also be TRUE. |
ggtheme |
ggplot2 theme function to apply. Default is ggplot2::theme_minimal. |
x_axis_label |
Label for the x axis. |
y_axis_label |
Label for the y 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 |
static |
If TRUE (or if the dataset is over 10,000 rows), the output will be static ggplot chart instead of an interactive ggplotly chart. Default is FALSE. |
A plotly-ized version of a ggplot bar plot.
make_barplot(dt = iris, bars = 'Species', value = 'Sepal.Length') make_barplot(dt = ggplot2::mpg, bars = 'manufacturer', break_bars_by = 'model', value = 'cty', horizontal = TRUE, sort_by_value = TRUE)
make_barplot(dt = iris, bars = 'Species', value = 'Sepal.Length') make_barplot(dt = ggplot2::mpg, bars = 'manufacturer', break_bars_by = 'model', value = 'cty', horizontal = TRUE, sort_by_value = TRUE)
Create a box plot from a data frame through ggplotly
make_boxplot( dt, value, groups = NULL, split_groups_by = NULL, jitter = FALSE, ggtheme = "minimal", x_axis_label = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = "plasma", static = FALSE )
make_boxplot( dt, value, groups = NULL, split_groups_by = NULL, jitter = FALSE, ggtheme = "minimal", x_axis_label = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = "plasma", static = FALSE )
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. |
split_groups_by |
Second column to split each group by (eg, create inidivudal boxplots within the 'groups'.) |
jitter |
Whether to add the actual values of each observation over the box plots. Only done when dt has 10,000 rows or less. |
ggtheme |
ggplot2 theme function to apply. Default is ggplot2::theme_minimal. |
x_axis_label |
Label for the x axis. |
y_axis_label |
Label for the y 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. |
static |
If TRUE (or if the dataset is over 10,000 rows), the output will be static ggplot chart instead of an interactive ggplotly chart. Default is FALSE. |
A plotly-ized version of a ggplot box plot.
make_boxplot(dt = ggplot2::mpg, value = 'hwy', groups = 'drv', jitter = TRUE)
make_boxplot(dt = ggplot2::mpg, value = 'hwy', groups = 'drv', jitter = TRUE)
Create a density plot from a data frame through ggplotly
make_density( dt, value, groups = NULL, faceted = TRUE, scales = "fixed", ggtheme = "minimal", x_axis_label = NULL, plot_palette = NULL, plot_palette_generator = "plasma", static = FALSE )
make_density( dt, value, groups = NULL, faceted = TRUE, scales = "fixed", ggtheme = "minimal", x_axis_label = NULL, plot_palette = NULL, plot_palette_generator = "plasma", static = FALSE )
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. |
faceted |
If TRUE (default), each group will be plotted separately. |
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. |
static |
If TRUE (or if the dataset is over 10,000 rows), the output will be static ggplot chart instead of an interactive ggplotly chart. Default is FALSE. |
A plotly-ized version of a ggplot density plot.
make_density(dt = iris, value = 'Sepal.Length', groups = 'Species') make_density(dt = iris, value = 'Sepal.Length', groups = 'Species', faceted = FALSE)
make_density(dt = iris, value = 'Sepal.Length', groups = 'Species') make_density(dt = iris, value = 'Sepal.Length', groups = 'Species', faceted = FALSE)
Plot a time series from a data frame through dygraph's interactive html plot interface
make_dygraph( dt, value, date, groups = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = "plasma", static = FALSE )
make_dygraph( dt, value, date, groups = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = "plasma", static = FALSE )
dt |
data.frame containing the data to plot. It must have a numerical variable, a date variable, and optionally a grouping variable to split the data and plot them as individual time series inside the same plot. |
value |
Name of the column of the data frame containing the numerical variables of the time series. |
date |
Name of the column containing the date variable. It must be already a date or time object. |
groups |
Name of the columns containing the different groups. |
y_axis_label |
Label for the y axis. x axis is the date (or time) so it is not needed |
plot_palette |
Character vector of hex codes specifying the colors to use on the plot. Default is RColorBrewer's Paired and Spectral colors concatenated. |
plot_palette_generator |
Palette from the viridis package used in case plot_palette is unspecified or insufficient for the number of colors required. |
static |
If TRUE (or if the dataset is over 10,000 rows), the output will be static ggplot chart instead of a dygraph. Default is FALSE. |
A dygraph of the numerical variable specified, optionally split by the values of 'groups'. If static is set to TRUE, it will return a ggplot line plot
dat <- data.frame(x = c(rnorm(100, 2, 4), rnorm(100, 6, 1), rnorm(100, 8, 2)), group = c(rep('A', 100), rep('B', 100), rep('C', 100)), date = rep(seq(as.Date("2020-01-01"), as.Date("2020-04-09"), 'days'), 3)) make_dygraph(dt = dat, value = 'x', date = 'date') make_dygraph(dt = dat, value = 'x', groups = 'group', date = 'date')
dat <- data.frame(x = c(rnorm(100, 2, 4), rnorm(100, 6, 1), rnorm(100, 8, 2)), group = c(rep('A', 100), rep('B', 100), rep('C', 100)), date = rep(seq(as.Date("2020-01-01"), as.Date("2020-04-09"), 'days'), 3)) make_dygraph(dt = dat, value = 'x', date = 'date') make_dygraph(dt = dat, value = 'x', groups = 'group', date = 'date')
Create a histogram plot from a data frame through ggplotly
make_histogram( dt, value, groups = NULL, binwidth = NULL, bins = 30, scales = "fixed", ggtheme = "minimal", x_axis_label = NULL, plot_palette = NULL, plot_palette_generator = "plasma", static = FALSE )
make_histogram( dt, value, groups = NULL, binwidth = NULL, bins = 30, scales = "fixed", ggtheme = "minimal", x_axis_label = NULL, plot_palette = NULL, plot_palette_generator = "plasma", static = FALSE )
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. |
static |
If TRUE (or if the dataset is over 10,000 rows), the output will be static ggplot chart instead of an interactive ggplotly chart. Default is FALSE. |
A plotly-ized version of a grouped ggplot histogram plot.
make_histogram(dt = iris, value = 'Sepal.Length', groups = 'Species')
make_histogram(dt = iris, value = 'Sepal.Length', groups = 'Species')
Create a line plot from a data frame through ggplotly
make_lineplot( dt, x, y, groups = NULL, faceted = FALSE, scales = "fixed", show_trend = FALSE, trend_method = "loess", ggtheme = "minimal", x_axis_label = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = "plasma", static = FALSE )
make_lineplot( dt, x, y, groups = NULL, faceted = FALSE, scales = "fixed", show_trend = FALSE, trend_method = "loess", ggtheme = "minimal", x_axis_label = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = "plasma", static = FALSE )
dt |
data.frame containing the data to plot. |
x |
Value on the x axis. |
y |
Value on the y axis. |
groups |
Name of the column containing the different groups. |
faceted |
If TRUE (default), each group will be plotted separately. |
scales |
From ggplot2::facet_wrap: Should scales be 'fixed', 'free', or free in one dimension ('free_x', 'free_y'). Default is 'fixed'. |
show_trend |
If TRUE, adds a ggplot2::geom_smooth() line to the plot. |
trend_method |
The method ggplot2::geom_smooth will use. Default is 'loess', which is a local polynomial regression fit |
ggtheme |
ggplot2 theme function to apply. Default is ggplot2::theme_minimal. |
x_axis_label |
Label for the x axis. |
y_axis_label |
Label for the y 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. |
static |
If TRUE (or if the dataset is over 10,000 rows), the output will be static ggplot chart instead of an interactive ggplotly chart. Default is FALSE. |
A plotly-ized version of a grouped ggplot line plot.
make_lineplot(dt = ggplot2::mpg, x = 'hwy', y = 'cty', groups = 'manufacturer', faceted = FALSE) make_lineplot(dt = ggplot2::mpg, x = 'hwy', y = 'cty', groups = 'manufacturer', faceted = TRUE, scales = 'free')
make_lineplot(dt = ggplot2::mpg, x = 'hwy', y = 'cty', groups = 'manufacturer', faceted = FALSE) make_lineplot(dt = ggplot2::mpg, x = 'hwy', y = 'cty', groups = 'manufacturer', faceted = TRUE, scales = 'free')
Create a raincloud plot from a data frame through ggplotly
make_raincloud( dt, value, groups = NULL, adjust = 0.5, include_boxplot = TRUE, include_mean = FALSE, include_median = TRUE, force_all_jitter_obs = FALSE, ggtheme = "minimal", x_axis_label = NULL, plot_palette = NULL, plot_palette_generator = "plasma", static = FALSE )
make_raincloud( dt, value, groups = NULL, adjust = 0.5, include_boxplot = TRUE, include_mean = FALSE, include_median = TRUE, force_all_jitter_obs = FALSE, ggtheme = "minimal", x_axis_label = NULL, plot_palette = NULL, plot_palette_generator = "plasma", static = FALSE )
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. |
adjust |
Width of the kernel bins. The smaller the value, the higher the resolution of the density. For full details, see ?ggplot2::stat_density. |
include_boxplot |
Include a boxplot over the raincloud. Default is TRUE. |
include_mean |
Mark the median of each distribution. Default is TRUE. |
include_median |
Mark the mean of each distribution. Default is FALSE. |
force_all_jitter_obs |
When the data has more than 1000 observations, the function will sample 1000 observations in order to keep the object reasonably small. If you need to override it, set this value to TRUE. |
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. |
static |
If TRUE (or if the dataset is over 10,000 rows), the output will be static ggplot chart instead of an interactive ggplotly chart. Default is FALSE. |
A plotly-ized version of a ggplot raincloud plot.
make_raincloud(dt = iris, value = 'Sepal.Width') make_raincloud(dt = iris, value = 'Sepal.Width', adjust = 1) make_raincloud(dt = iris, value = 'Petal.Length', groups = 'Species', static = TRUE, adjust = 1) make_raincloud(dt = iris, value = 'Sepal.Length', groups = 'Species', adjust = 1)
make_raincloud(dt = iris, value = 'Sepal.Width') make_raincloud(dt = iris, value = 'Sepal.Width', adjust = 1) make_raincloud(dt = iris, value = 'Petal.Length', groups = 'Species', static = TRUE, adjust = 1) make_raincloud(dt = iris, value = 'Sepal.Length', groups = 'Species', adjust = 1)
Create a scatter plot from a data frame through ggplotly
make_scatterplot( dt, x, y, groups = NULL, faceted = FALSE, scales = "fixed", show_trend = FALSE, trend_method = "loess", ggtheme = "minimal", x_axis_label = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = "plasma", static = FALSE )
make_scatterplot( dt, x, y, groups = NULL, faceted = FALSE, scales = "fixed", show_trend = FALSE, trend_method = "loess", ggtheme = "minimal", x_axis_label = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = "plasma", static = FALSE )
dt |
data.frame containing the data to plot. |
x |
Value on the x axis. |
y |
Value on the y axis. |
groups |
Name of the column containing the different groups. |
faceted |
If TRUE (default), each group will be plotted separately. |
scales |
From ggplot2::facet_wrap: Should scales be 'fixed', 'free', or free in one dimension ('free_x', 'free_y'). Default is 'fixed'. |
show_trend |
If TRUE, adds a ggplot2::geom_smooth() line to the plot. |
trend_method |
The method ggplot2::geom_smooth will use. Default is 'loess', which is a local polynomial regression fit |
ggtheme |
ggplot2 theme function to apply. Default is ggplot2::theme_minimal. |
x_axis_label |
Label for the x axis. |
y_axis_label |
Label for the y 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. |
static |
If TRUE (or if the dataset is over 10,000 rows), the output will be static ggplot chart instead of an interactive ggplotly chart. Default is FALSE. |
A plotly-ized version of a grouped ggplot scatter plot.
make_scatterplot(dt = ggplot2::mpg, x = 'hwy', y = 'cty', groups = 'manufacturer', faceted = FALSE) make_scatterplot(dt = ggplot2::mpg, x = 'hwy', y = 'cty', groups = 'manufacturer', faceted = TRUE, scales = 'free')
make_scatterplot(dt = ggplot2::mpg, x = 'hwy', y = 'cty', groups = 'manufacturer', faceted = FALSE) make_scatterplot(dt = ggplot2::mpg, x = 'hwy', y = 'cty', groups = 'manufacturer', faceted = TRUE, scales = 'free')
Detects which make_* function is passed and builds a generic name based on its parameters.
make_title(fun, params)
make_title(fun, params)
fun |
chronicle make_* function |
params |
parameters for fun |
A generic title for the plot
make_title(fun = chronicle::make_barplot, params = list(value = 'Amount', bars = 'Country', break_bars_by = 'Region')) make_title(fun = chronicle::make_raincloud, params = list(value = 'value', groups = 'species'))
make_title(fun = chronicle::make_barplot, params = list(value = 'Amount', bars = 'Country', break_bars_by = 'Region')) make_title(fun = chronicle::make_raincloud, params = list(value = 'value', groups = 'species'))
Create a violin plot from a data frame through ggplotly
make_violin( dt, value, groups = NULL, jitter = TRUE, ggtheme = "minimal", x_axis_label = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = "plasma", static = FALSE )
make_violin( dt, value, groups = NULL, jitter = TRUE, ggtheme = "minimal", x_axis_label = NULL, y_axis_label = NULL, plot_palette = NULL, plot_palette_generator = "plasma", static = FALSE )
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. |
jitter |
Whether to add the actual values of each observation over the violin plots. Only done when dt has 10,000 rows or less. |
ggtheme |
ggplot2 theme function to apply. Default is ggplot2::theme_minimal. |
x_axis_label |
Label for the x axis. |
y_axis_label |
Label for the y 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 |
static |
If TRUE (or if the dataset is over 10,000 rows), the output will be static ggplot chart instead of an interactive ggplotly chart. Default is FALSE. |
A plotly-ized version of a ggplot violin plot.
make_violin(dt = ggplot2::mpg, value = 'hwy', groups = 'drv')
make_violin(dt = ggplot2::mpg, value = 'hwy', groups = 'drv')
Currently supported: prettydoc, ioslides, tufte, flexdashboard, slidy_presentation, html_document, html_notebook.
output_config( output_format, title = NULL, author = NULL, include_date = TRUE, number_sections = FALSE, table_of_content = FALSE, table_of_content_depth = 1, fig_width = 8, fig_height = 5, plot_palette = NULL, plot_palette_generator = "plasma", rmdformats_theme = "downcute", prettydoc_theme = "leonids", docx_reference_file = NULL, pptx_reference_file = NULL, html_theme = "simplex", rticles_template = "arxiv_article", custom_output = NULL )
output_config( output_format, title = NULL, author = NULL, include_date = TRUE, number_sections = FALSE, table_of_content = FALSE, table_of_content_depth = 1, fig_width = 8, fig_height = 5, plot_palette = NULL, plot_palette_generator = "plasma", rmdformats_theme = "downcute", prettydoc_theme = "leonids", docx_reference_file = NULL, pptx_reference_file = NULL, html_theme = "simplex", rticles_template = "arxiv_article", custom_output = NULL )
output_format |
The format of the R Markdown file. |
title |
Title of the report. If NULL (default), no title will be added. |
author |
Author of the report. If NULL (default), no author will be added. |
include_date |
Whether or not to include the date as part of the header. Default is TRUE. |
number_sections |
Whether or not to number the sections and subsections of the report. |
table_of_content |
Whether or not to include a table fo content at the beginning of the report. |
table_of_content_depth |
The depth of sections and subsections to be displayed on the table of content. |
fig_width |
Set the global figure width or the rmarkdown file. |
fig_height |
Set the global figure height or the rmarkdown file. |
plot_palette |
Character vector of hex codes to use on plots. |
plot_palette_generator |
Palette from the viridis package used in case plot_palette is unspecified or insufficient for the number of colors required. Default value is 'plasma', and possible values are 'viridis', 'inferno', 'magma', 'plasma', 'cividis'. |
rmdformats_theme |
The theme to be used for [rmdformats](https://github.com/juba/rmdformats) outputs. Default is "downcute", and possible values are "downcute", "robobook", "material", "readthedown", "html_clean", "html_docco". |
prettydoc_theme |
Name of the theme used on [prettydoc](https://prettydoc.statr.me/themes.html). Default is "leonids", and ossible values are "cayman", "tactile", "architect", "leonids", "hpstr". |
docx_reference_file |
The path for a blank Microsoft Word document to use as template for the 'word_document' output. |
pptx_reference_file |
The path for a blank Microsoft PowerPoint document to use as template for the 'powerpoint_presentation' output. |
html_theme |
The theme to be used for [hmtl_document](https://www.datadreaming.org/post/r-markdown-theme-gallery/) outputs. Default is "simplex". |
rticles_template |
The theme to be used fo [rticles](https://github.com/rstudio/rticles). Default is "arxiv_article" |
custom_output |
[Experimental] This is to get output formats not currently supported. It should be a YAML element with the corresponding output |
The lines needed in the yaml header of an R Markdown file to render as the specified output type.
cat(output_config('prettydoc')) cat(output_config('ioslides'))
cat(output_config('prettydoc')) cat(output_config('ioslides'))
Make raincloud plots for each numerical variable on a table, and barplots for each categorical variable.
plot_columns(dt, by_column = NULL)
plot_columns(dt, by_column = NULL)
dt |
Table to be plotted. |
by_column |
Name of the column to use as groups for all the other plots |
A list of plotly::ggplotly objects, one for each column of the table.
chronicle::plot_columns(dt = iris, by_column = 'Species')
chronicle::plot_columns(dt = iris, by_column = 'Species')
Render the report using all objects from the global environment
render_report( report = "", output_format = "rmdformats", filename = paste("report", gsub(x = Sys.Date(), pattern = "-", replacement = ""), sep = "_"), title = NULL, author = NULL, include_date = TRUE, directory = getwd(), keep_rmd = FALSE, render_reports = TRUE, number_sections = FALSE, table_of_content = FALSE, table_of_content_depth = 1, fig_width = 9, fig_height = 5, plot_palette = NULL, plot_palette_generator = "plasma", rmdformats_theme = "downcute", prettydoc_theme = "leonids", docx_reference_file = NULL, pptx_reference_file = NULL, rticles_template = "arxiv_article", html_theme = "simplex", custom_output = NULL )
render_report( report = "", output_format = "rmdformats", filename = paste("report", gsub(x = Sys.Date(), pattern = "-", replacement = ""), sep = "_"), title = NULL, author = NULL, include_date = TRUE, directory = getwd(), keep_rmd = FALSE, render_reports = TRUE, number_sections = FALSE, table_of_content = FALSE, table_of_content_depth = 1, fig_width = 9, fig_height = 5, plot_palette = NULL, plot_palette_generator = "plasma", rmdformats_theme = "downcute", prettydoc_theme = "leonids", docx_reference_file = NULL, pptx_reference_file = NULL, rticles_template = "arxiv_article", html_theme = "simplex", custom_output = NULL )
report |
Character string containing all the R Markdown chunks previously added (through chronicle::add_* functions.) Default is ”, an empty report. |
output_format |
The format of the R Markdown file. Default is prettydoc. Currently supported: 'bookdown', 'github_document', 'html_document', 'html_notebook', 'ioslides', 'pagedown', 'powerpoint_presentation', 'pdf', 'prettydoc', 'rmdformats', 'rolldown', 'rticles', 'slidy_presentation', 'tufte_handout', 'tufte_html', 'word_document'. Also 'felxdashboard' and 'xaringan' technically compile, but the layout is stiff in flexdashborad and altogether incorrect in xaringan. |
filename |
The name of the .html file(s) created. If NULL (default), no author will be added. |
title |
Title of the report. If NULL (default), no title will be added. |
author |
Author of the report. If NULL (default), no author will be added. |
include_date |
Whether or not to include the date as part of the header. Default is TRUE. |
directory |
The directory in which to render the .html report |
keep_rmd |
Whether or not to keep the .Rmd file. Default is false. |
render_reports |
Whether or not to render the reports. Default is TRUE. Set render_reports = FALSE and keep_rmd = TRUE to only build the R Markdown files |
number_sections |
Whether or not to number the sections and subsections fo the report. |
table_of_content |
Whether or not to include a table fo content at the beginning of the report. Some formats does not allow overriding this. |
table_of_content_depth |
The depth of sections and subsections to be displayed on the table of content. |
fig_width |
Set the global figure width or the rmarkdown file. |
fig_height |
Set the global figure height or the rmarkdown file. |
plot_palette |
Character vector of hex codes to use on plots. |
plot_palette_generator |
Palette from the [viridis](https://cran.r-project.org/web/packages/viridis/vignettes/intro-to-viridis.html#the-color-scales) package used in case plot_palette is unspecified (or insufficient for the number of colors required.) Default value is 'plasma', and possible values are 'viridis', 'inferno', 'magma', 'plasma', 'cividis', 'mako', 'rocket', and 'turbo'. |
rmdformats_theme |
The theme to be used for [rmdformats](https://github.com/juba/rmdformats) outputs. Default is "downcute", and possible values are "downcute", "robobook", "material", "readthedown", "html_clean", "html_docco". |
prettydoc_theme |
Name of the theme used on [prettydoc](https://prettydoc.statr.me/themes.html). Default is "leonids", and ossible values are "cayman", "tactile", "architect", "leonids", "hpstr". |
docx_reference_file |
The path for a blank Microsoft Word document to use as template for the 'word_document' output. |
pptx_reference_file |
The path for a blank Microsoft PowerPoint document to use as template for the 'powerpoint_presentation' output. |
rticles_template |
The theme to be used fo [rticles](https://github.com/rstudio/rticles). Default is "arxiv_article" |
html_theme |
The theme to be used for [hmtl_document](https://www.datadreaming.org/post/r-markdown-theme-gallery/) outputs. Default is "simplex". |
custom_output |
[Experimental] A custom element for a yaml structure to specify as the output format of the R Markdown file. This is to get output formats not currently supported.#' |
Renders the report as an HTML file.
# report_demo <- add_title(title = 'This is how a chronicle report looks', title_level = 1) %>% # add_density(dt = iris, groups = 'Species', value = 'Sepal.Length', faceted = F) %>% # add_boxplot(dt = iris, groups = 'Species', value = 'Sepal.Length') %>% # add_barplot(dt = iris, bars = 'Species', value = 'Sepal.Length') # add_table(table = iris, # table_title = 'This is the iris dataset. Smells good!', # html_table_type = 'kable') %>% # add_table(table = mpg, # table_title = 'And this is mpg', # html_table_type = 'DT') # render_report(report = report_demo, # title = 'Demo Output', # author = 'This is the author', # filename = 'demo_output', # output_format = 'prettydoc', # keep_rmd = TRUE)
# report_demo <- add_title(title = 'This is how a chronicle report looks', title_level = 1) %>% # add_density(dt = iris, groups = 'Species', value = 'Sepal.Length', faceted = F) %>% # add_boxplot(dt = iris, groups = 'Species', value = 'Sepal.Length') %>% # add_barplot(dt = iris, bars = 'Species', value = 'Sepal.Length') # add_table(table = iris, # table_title = 'This is the iris dataset. Smells good!', # html_table_type = 'kable') %>% # add_table(table = mpg, # table_title = 'And this is mpg', # html_table_type = 'DT') # render_report(report = report_demo, # title = 'Demo Output', # author = 'This is the author', # filename = 'demo_output', # output_format = 'prettydoc', # keep_rmd = TRUE)
Creates an Rmarkdown report plotting each column of a dataset. Categorical columns are plotted in bar plots, and numerical columns are plotted in box plots. If 'by_column' is provided, these plots will be grouped by the values of that column
report_columns( dt, by_column = NULL, filename = NULL, output_format = "rmdformats", title = NULL, author = NULL, plot_palette = NULL, plot_palette_generator = "plasma", horizontal_bars = TRUE, sort_bars_value = TRUE, sort_bars_decreasingly = TRUE, rmdformats_theme = "downcute", prettydoc_theme = "leonids", number_sections = TRUE, table_of_content = TRUE, table_of_content_depth = 1, fig_width = 9, fig_height = 4, directory = getwd(), keep_rmd = FALSE, render_reports = TRUE )
report_columns( dt, by_column = NULL, filename = NULL, output_format = "rmdformats", title = NULL, author = NULL, plot_palette = NULL, plot_palette_generator = "plasma", horizontal_bars = TRUE, sort_bars_value = TRUE, sort_bars_decreasingly = TRUE, rmdformats_theme = "downcute", prettydoc_theme = "leonids", number_sections = TRUE, table_of_content = TRUE, table_of_content_depth = 1, fig_width = 9, fig_height = 4, directory = getwd(), keep_rmd = FALSE, render_reports = TRUE )
dt |
Table to be studied. |
by_column |
Name of the column to use as groups for all the other plots. Default is NULL. |
filename |
Name of the output file. If not supplied, a generic name will be created. |
output_format |
The format of the R Markdown output. Default is 'rmdformats'. |
title |
Title of the report. If NULL (default), no title will be added. |
author |
Author of the report. Default is NULL. |
plot_palette |
Character vector of hex codes to use on plots. |
plot_palette_generator |
Palette from the viridis package used in case plot_palette is unspecified (or insufficient for the number of colors required.) Default value is 'plasma', and possible values are 'viridis', 'inferno', 'magma', 'plasma', 'cividis'. |
horizontal_bars |
Plot bars for categorical variables horizontally. Default is FALSE |
sort_bars_value |
Sort the bars by value. Default is FALSE. |
sort_bars_decreasingly |
Sort the bars decreasingly. Default is TRUE. |
rmdformats_theme |
The theme to be used for [rmdformats](https://github.com/juba/rmdformats) outputs. Default is "downcute", and possible values are "downcute", "robobook", "material", "readthedown", "html_clean", "html_docco". |
prettydoc_theme |
Name of the theme used on prettydoc. Default is leonids. |
number_sections |
Whether or not to number the sections and subsections fo the report. |
table_of_content |
Whether or not to include a table fo content at the beginning of the report. |
table_of_content_depth |
The depth of sections and subsections to be displayed on the table of content. |
fig_width |
Set the global figure width or the rmarkdown file. |
fig_height |
Set the global figure height or the rmarkdown file. |
directory |
The directory in which to render the .html report |
keep_rmd |
Whether or not to keep the .Rmd file. Default is false. |
render_reports |
Whether or not to render the reports. Default is TRUE. Set render_reports = FALSE and keep_rmd = TRUE to only build the R Markdown files |
Creates an HTML file with a plot for each column on the given table: a box plot for each numerical variable, and a bar plot for each categorical variable.
# chronicle::report_columns(dt = iris, # by_column = 'Species', # horizontal_bars = TRUE, # keep_rmd = TRUE)
# chronicle::report_columns(dt = iris, # by_column = 'Species', # horizontal_bars = TRUE, # keep_rmd = TRUE)
Returns the count of '#' corresponding to a given title level
rmd_title_level(level)
rmd_title_level(level)
level |
R Markdonw title level |
'#', '##', '###' and so on, depending on the title level
rmd_title_level(1) rmd_title_level(3)
rmd_title_level(1) rmd_title_level(3)
Change column classes with a named vector
set_classes( dt, character = NULL, integer = NULL, double = NULL, logical = NULL, factor = NULL )
set_classes( dt, character = NULL, integer = NULL, double = NULL, logical = NULL, factor = NULL )
dt |
Table whose column types will be changed |
character |
The columns that will be coerced to character. |
integer |
The columns that will be coerced to integer. |
double |
The columns that will be coerced to double. |
logical |
The columns that will be coerced to logical. |
factor |
The columns that will be coerced to factor. |
Changes by reference the types of the specified columns
library(chronicle) iris_changed <- chronicle::set_classes(dt = iris, character = 'Species', integer = c('Sepal.Length', 'Sepal.Width')) purrr::map_chr(iris_changed, class)
library(chronicle) iris_changed <- chronicle::set_classes(dt = iris, character = 'Species', integer = c('Sepal.Length', 'Sepal.Width')) purrr::map_chr(iris_changed, class)