Learn R Programming

⚠️There's a newer version (0.3) of this package.Take me there.

{chronicle}

This is an R package for rendering attractive R Markdown html files, with interactive html widgets like plotly charts, dygraphs and DataTables. It is built using a layered paradigm that will be familiar to any {ggplot2} or {tensorflow} R user.

A quick demo:

install.packages('chronicle')
library(chronicle)

demo_report <- 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_table(table = iris, table_title = 'This is the iris dataset. Smells good!', html_table_type = 'DT') %>%
    add_boxplot(dt = iris, groups = 'Species', value = 'Sepal.Length') %>%
    add_barplot(dt = iris, bars = 'Species', value = 'Sepal.Length')
    
render_report(report = demo_report,
              filename = 'chronicle_demo',
              output_format = c('prettydoc', 'ioslides'),
              title = 'Demo Output',
              author = 'You created this',
              keep_rmd = TRUE)

And you can see the ouput of the prettydoc format here.

How to use chronicle?

As R Markdown files are a collection of chunks, you can start off a report just by calling any of the add_* family of functions to add a chunk with a specific type of content. These currently include:

  • add_barplot
  • add_boxplot
  • add_chunk
  • add_code
  • add_density
  • add_dygraph
  • add_histogram
  • add_lineplot
  • add_table
  • add_text
  • add_title
  • add_scatterplot
  • add_violin

Each of these functions has its own set of parameters, and aim to take the burden of sophistication from the user, to help you create interactive data visualizations by just specifying the parameters of each function. Be sure to go through ?add_* to see the full set of options each function has.

These functions will create chunks that will be concatenated into your report, similar to adding layers to a ggplot.

After having all your chunks, just call render_report() to knit the html file. This function will create the yaml header for all the output formats you selected, and render all of them in a single call. Albeit quite unformed yet, chronicle currently supports 'prettydoc', 'ioslides', 'tufte', 'flexdashboard', 'slidy_presentation', 'html_document' and 'html_notebook', althouhg I heavily suggest sticking to prettydoc and ioslides for now.

A great upside of using chronicle is that the report is rendered in you global environment, which means that you will not have to repeat all the data processing as you would have if you knitted traditionally. You can also choose to keep the .Rmd file for later reproducibility. As shown in the demo, this is the call that renders the R Markdown file into a prettydoc and an ioslides output:

render_report(report <- demo_report
              filename = 'chronicle_demo',
              output_format = c('prettydoc', 'ioslides')
              title = 'Demo Output',
              author = 'You created this',
              keep_rmd = TRUE)

What's next for chronicle?

  • Add other interactive output formats (mainly bookdown), and polish the outputs of the ones currently supported.
  • Add non-interactive outputs (where you cannot embed html objects, but it can have plots and tables as static figures) like word, powerpoint, pagedown, and git readme.
  • Add new add_* functions, and additional parameters to the existing ones.
  • Try out other plotting engines besides plotly: ggiraph, e_charts, highcharter*, D3 (!).

Copy Link

Version

Install

install.packages('chronicle')

Monthly Downloads

308

Version

0.2.1

License

GPL (>= 3)

Maintainer

Philippe Heymans Smith

Last Published

January 25th, 2021

Functions in chronicle (0.2.1)

add_scatterplot

Add a scatter plot to a chronicle report
add_boxplot

Add a box plot to a chronicle report
add_chunk

Transforms a function call into an Rmarkdown chunk
add_histogram

Add a histogram plot to a chronicle report
add_density

Add a density plot to a chronicle report
add_lineplot

Add a line plot to a chronicle report
add_barplot

Add a bar plot to a chronicle report
add_dygraph

Add a dygraph to a chronicle report
add_table

Add a table to a chronicle report
add_code

#' Add formatted code chunks to a chronicle Rmarkdown report
make_lineplot

Create a line plot from a data frame through ggplotly
make_title

Guess a title out of function parameters
make_violin

Create a violin plot from a data frame through ggplotly
make_density

Create a density plot from a data frame through ggplotly
make_boxplot

Create a box plot from a data frame through ggplotly
report_columns

HTML interactive report detailing each column on a table
new_report

Create the initial Rmarkdown header for a report
output_config

Wrapper to update chronicle from github
make_histogram

Create a histogram plot from a data frame through ggplotly
make_dygraph

Plot a time series from a data frame through dygraph's interactive html plot interface
add_text

Add text to a chronicle Rmarkdown report
make_barplot

Create a bar plot from a data frame through ggplotly
add_violin

Add a violin plot to a chronicle report
make_scatterplot

Create a scatter plot from a data frame through ggplotly
add_title

Add a titled section to a chronicle Rmarkdown report
plot_columns

Plot all columns of a table
render_report

Render the report using all objects from the global environment