chronicle Showcase

The Author Goes Here

2021-06-24

This is how a chronicle report looks

This is a showcase of the outputs possible with the {chronicle} R package. For a complete how-to, please refer to the package’s github page.

This showcase includes all the elements currently supported by chronicle as of version 0.3.

Each element has its chronicle::make_* call for reference, which allows to call each one independently. If you want to create a full R Markdown report with chronicle, use the add_* family of functions instead, which have the same parametes as its corresponding make_*in this showcase

Barplots

chronicle::add_barplot()

Simple bar plot

chronicle::make_barplot(dt = iris,
                        bars = 'Species',
                        value = 'Sepal.Length',
                        horizontal = FALSE,
                        sort_by_value = FALSE,
                        sort_decreasing = TRUE,
                        ggtheme = 'minimal',
                        plot_palette = params$plot_palette,
                        plot_palette_generator = params$plot_palette_generator,
                        static = params$set_static)

Bars broken by other group

chronicle::make_barplot(dt = ggplot2::mpg,
                        bars = 'manufacturer',
                        value = 'cty',
                        break_bars_by = 'trans',
                        horizontal = FALSE,
                        sort_by_value = FALSE,
                        sort_decreasing = TRUE,
                        ggtheme = 'minimal',
                        plot_palette = params$plot_palette,
                        plot_palette_generator = params$plot_palette_generator,
                        static = params$set_static)

Bars sorted by value

chronicle::make_barplot(dt = ggplot2::mpg,
                        bars = 'manufacturer',
                        value = 'cty',
                        horizontal = FALSE,
                        sort_by_value = TRUE,
                        sort_decreasing = TRUE,
                        ggtheme = 'minimal',
                        plot_palette = params$plot_palette,
                        plot_palette_generator = params$plot_palette_generator,
                        static = params$set_static)

Bars sorted by value and broken by another column

chronicle::make_barplot(dt = ggplot2::mpg,
                        bars = 'manufacturer',
                        value = 'cty',
                        break_bars_by = 'trans',
                        horizontal = FALSE,
                        sort_by_value = TRUE,
                        sort_decreasing = TRUE,
                        ggtheme = 'minimal',
                        plot_palette = params$plot_palette,
                        plot_palette_generator = params$plot_palette_generator,
                        static = params$set_static)

Horizontally

chronicle::make_barplot(dt = ggplot2::mpg,
                        bars = 'manufacturer',
                        value = 'cty',
                        break_bars_by = 'trans',
                        horizontal = TRUE,
                        sort_by_value = TRUE,
                        sort_decreasing = TRUE,
                        ggtheme = 'minimal',
                        plot_palette = params$plot_palette,
                        plot_palette_generator = params$plot_palette_generator,
                        static = params$set_static)

Boxplots

chronicle::add_boxplot()

Simple box plot

chronicle::make_boxplot(dt = iris,
                        value = 'Sepal.Length',
                        jitter = FALSE,
                        plot_palette = params$plot_palette,
                        plot_palette_generator = params$plot_palette_generator,
                        static = params$set_static)

Box plot by groups

chronicle::make_boxplot(dt = iris,
                        value = 'Sepal.Length',
                        groups = 'Species',
                        jitter = FALSE,
                        plot_palette = params$plot_palette,
                        plot_palette_generator = params$plot_palette_generator,
                        static = params$set_static)

Box plot with jitter

chronicle::make_boxplot(dt = iris,
                        value = 'Sepal.Length',
                        groups = 'Species',
                        jitter = TRUE,
                        plot_palette = params$plot_palette,
                        plot_palette_generator = params$plot_palette_generator,
                        static = params$set_static)

Split each group by a second variable

chronicle::make_boxplot(dt = palmerpenguins::penguins,
                        value = 'body_mass_g',
                        groups = 'island',
                        split_groups_by = 'sex',
                        jitter = TRUE,
                        plot_palette = params$plot_palette,
                        plot_palette_generator = params$plot_palette_generator,
                        static = params$set_static)

Code

chronicle::add_code()

This is an empty canvas for you to include any code you want.

This is some code:

data.table(iris)[, .N, Species]

It can also be evaluated!

library(data.table)
data.table(iris)[, .N, Species]
##       Species     N
##        <fctr> <int>
## 1:     setosa    50
## 2: versicolor    50
## 3:  virginica    50

Densities

chronicle::add_density()

Basic density

chronicle::make_density(dt = iris,
                        value = 'Sepal.Length',
                        faceted = TRUE,
                        scales = 'fixed',
                        plot_palette = params$plot_palette,
                        plot_palette_generator = params$plot_palette_generator,
                        static = params$set_static)

Density by group

chronicle::make_density(dt = iris,
                        value = 'Sepal.Length',
                        groups = 'Species',
                        faceted = FALSE,
                        scales = 'fixed',
                        plot_palette = params$plot_palette,
                        plot_palette_generator = params$plot_palette_generator,
                        static = params$set_static)

Faceted densities

chronicle::make_density(dt = iris,
                        value = 'Sepal.Length',
                        groups = 'Species',
                        faceted = TRUE,
                        scales = 'fixed',
                        plot_palette = params$plot_palette,
                        plot_palette_generator = params$plot_palette_generator,
                        static = params$set_static)

dygraphs

chronicle::add_dygraph()

Simple dygraph (in static outputs it will be replaced by line plots)

chronicle::make_dygraph(dt = dat,
                        value = 'x',
                        date = 'date',
                        plot_palette = params$plot_palette,
                        plot_palette_generator = params$plot_palette_generator,
                        static = params$set_static)

Dygraph by groups

chronicle::make_dygraph(dt = dat,
                        value = 'x',
                        date = 'date',
                        groups = 'group',
                        plot_palette = params$plot_palette,
                        plot_palette_generator = params$plot_palette_generator,
                        static = params$set_static)

Histograms

chronicle::add_histogram

Basic histogram

chronicle::make_histogram(dt = iris,
                          value = 'Sepal.Length',
                          scales = 'fixed',
                          plot_palette = params$plot_palette,
                          plot_palette_generator = params$plot_palette_generator,
                          static = params$set_static)

Faceted histogram by groups

chronicle::make_histogram(dt = iris,
                          value = 'Sepal.Length',
                          groups = 'Species',
                          scales = 'fixed',
                          plot_palette = params$plot_palette,
                          plot_palette_generator = params$plot_palette_generator,
                          static = params$set_static)

Images

chronicle::add_image

This is a test image

Line plots

chronicle::add_lineplot()

Simple line plot

chronicle::make_lineplot(dt = dat,
                         x = 'date',
                         y = 'x',
                         plot_palette = params$plot_palette,
                         plot_palette_generator = params$plot_palette_generator,
                         static = params$set_static)

Line plot with trend

chronicle::make_lineplot(dt = dat,
                         x = 'date',
                         y = 'x',
                         groups = 'group',
                         faceted = FALSE,
                         show_trend = TRUE,
                         plot_palette = params$plot_palette,
                         plot_palette_generator = params$plot_palette_generator,
                         static = params$set_static)

Line plot with linear trend

chronicle::make_lineplot(dt = dat,
                         x = 'date',
                         y = 'x',
                         groups = 'group',
                         faceted = FALSE,
                         show_trend = TRUE,
                         trend_method = 'lm',
                         plot_palette = params$plot_palette,
                         plot_palette_generator = params$plot_palette_generator,
                         static = params$set_static)

Faceted line plot

chronicle::make_lineplot(dt = dat,
                         x = 'date',
                         y = 'x',
                         groups = 'group',
                         faceted = TRUE,
                         show_trend = TRUE,
                         plot_palette = params$plot_palette,
                         plot_palette_generator = params$plot_palette_generator,
                         static = params$set_static)

Rain cloud plots

chronicle::add_raincloud()

Simple rain cloud

chronicle::make_raincloud(dt = iris,
                          value = 'Sepal.Length',
                          adjust = 0.5,
                          include_boxplot = TRUE,
                          include_mean = FALSE,
                          include_median = TRUE,
                          force_all_jitter_obs = FALSE,
                          ggtheme = 'minimal',
                          plot_palette = params$plot_palette,
                          plot_palette_generator = params$plot_palette_generator,
                          static = params$set_static)

Rain cloud by group

chronicle::make_raincloud(dt = iris,
                          value = 'Sepal.Length',
                          groups = 'Species',
                          adjust = 0.5,
                          include_boxplot = TRUE,
                          include_mean = FALSE,
                          include_median = TRUE,
                          force_all_jitter_obs = FALSE,
                          ggtheme = 'minimal',
                          plot_palette = params$plot_palette,
                          plot_palette_generator = params$plot_palette_generator,
                          static = params$set_static)

Larger denisty kernel

chronicle::make_raincloud(dt = iris,
                          value = 'Sepal.Length',
                          groups = 'Species',
                          adjust = 1,
                          include_boxplot = TRUE,
                          include_mean = FALSE,
                          include_median = TRUE,
                          force_all_jitter_obs = FALSE,
                          ggtheme = 'minimal',
                          plot_palette = params$plot_palette,
                          plot_palette_generator = params$plot_palette_generator,
                          static = params$set_static)

No boxplot, just the median

chronicle::make_raincloud(dt = iris,
                          value = 'Sepal.Length',
                          groups = 'Species',
                          adjust = 1,
                          include_boxplot = FALSE,
                          include_mean = FALSE,
                          include_median = TRUE,
                          force_all_jitter_obs = FALSE,
                          ggtheme = 'minimal',
                          plot_palette = params$plot_palette,
                          plot_palette_generator = params$plot_palette_generator,
                          static = params$set_static)

With the mean instead of the boxplot

chronicle::make_raincloud(dt = iris,
                          value = 'Sepal.Length',
                          groups = 'Species',
                          adjust = 1,
                          include_boxplot = FALSE,
                          include_mean = TRUE,
                          include_median = FALSE,
                          force_all_jitter_obs = FALSE,
                          ggtheme = 'minimal',
                          plot_palette = params$plot_palette,
                          plot_palette_generator = params$plot_palette_generator,
                          static = params$set_static)

Scatter plots

chronicle::add_scatterplot()

Simple scatter plot

chronicle::make_scatterplot(dt = iris,
                            x = 'Sepal.Length',
                            y = 'Sepal.Width',
                            plot_palette = params$plot_palette,
                            plot_palette_generator = params$plot_palette_generator,
                            static = params$set_static)

Scatter plot with groups

chronicle::make_scatterplot(dt = iris,
                            x = 'Sepal.Length',
                            y = 'Sepal.Width',
                            groups = 'Species',
                            faceted = FALSE,
                            show_trend = FALSE,
                            plot_palette = params$plot_palette,
                            plot_palette_generator = params$plot_palette_generator,
                            static = params$set_static)

Faceted scatter plot with trend

chronicle::make_scatterplot(dt = iris,
                            x = 'Sepal.Length',
                            y = 'Sepal.Width',
                            groups = 'Species',
                            faceted = TRUE,
                            show_trend = TRUE,
                            plot_palette = params$plot_palette,
                            plot_palette_generator = params$plot_palette_generator,
                            static = params$set_static)

Tables

chronicle::add_table()

kable

species island bill_length_mm bill_depth_mm flipper_length_mm body_mass_g sex year
Adelie Torgersen 39.1 18.7 181 3750 male 2007
Adelie Torgersen 39.5 17.4 186 3800 female 2007
Adelie Torgersen 40.3 18.0 195 3250 female 2007
Adelie Torgersen NA NA NA NA NA 2007
Adelie Torgersen 36.7 19.3 193 3450 female 2007
Adelie Torgersen 39.3 20.6 190 3650 male 2007

DT

Violins

chronicle::add_violin()

Simple violin plot

chronicle::make_violin(dt = iris,
                       value = 'Sepal.Length',
                       plot_palette = params$plot_palette,
                       plot_palette_generator = params$plot_palette_generator,
                       static = params$set_static)

Violin plot by group

chronicle::make_violin(dt = iris,
                       value = 'Sepal.Length',
                       groups = 'Species',
                       plot_palette = params$plot_palette,
                       plot_palette_generator = params$plot_palette_generator,
                       static = params$set_static)

Big Bonus! report_columns()

chronicle also includes a function called report_columns(), that will create an entire chronicle report for a single dataset. It includes a comprehensive summary of the data through the skimr::skim() function, along with one plot for each column present in the data: bar plots for categorical variables and rain cloud plots for numerical variables. This gives you an immediate view of a dataset with a single line of code!

report_columns(dt = palmerpenguins::penguins,
               by_column = 'species')

you can see the example of this output here

sessionInfo

sessionInfo()
## R version 4.1.0 (2021-05-18)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19042)
## 
## Matrix products: default
## 
## locale:
## [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
## [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
## [5] LC_TIME=English_United States.1252    
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] chronicle_0.3     data.table_1.13.6 magrittr_2.0.1   
## 
## loaded via a namespace (and not attached):
##  [1] tufte_0.9            lattice_0.20-44      tidyr_1.1.2          palmerpenguins_0.1.0
##  [5] zoo_1.8-8            digest_0.6.27        R6_2.5.0             repr_1.1.3          
##  [9] evaluate_0.14        httr_1.4.2           ggplot2_3.3.3        highr_0.9           
## [13] pillar_1.4.7         tictoc_1.0.1         rlang_0.4.11         lazyeval_0.2.2      
## [17] rstudioapi_0.13      Matrix_1.2-18        DT_0.17              rmarkdown_2.8       
## [21] labeling_0.4.2       splines_4.1.0        rolldown_0.1         readr_1.4.0         
## [25] stringr_1.4.0        htmlwidgets_1.5.3    munsell_0.5.0        tinytex_0.32        
## [29] compiler_4.1.0       xfun_0.23            pkgconfig_2.0.3      base64enc_0.1-3     
## [33] mgcv_1.8-35          htmltools_0.5.1.1    tidyselect_1.1.0     tibble_3.0.4        
## [37] gridExtra_2.3        bookdown_0.21        viridisLite_0.4.0    crayon_1.3.4        
## [41] dplyr_1.0.2          withr_2.3.0          grid_4.1.0           nlme_3.1-151        
## [45] jsonlite_1.7.2       gtable_0.3.0         lifecycle_1.0.0      scales_1.1.1        
## [49] rmdformats_1.0.1     stringi_1.6.2        farver_2.0.3         viridis_0.6.1       
## [53] skimr_2.1.2          dygraphs_1.1.1.6     ellipsis_0.3.2       xts_0.12.1          
## [57] generics_0.1.0       vctrs_0.3.8          RColorBrewer_1.1-2   tools_4.1.0         
## [61] glue_1.4.2           purrr_0.3.4          hms_1.1.0            crosstalk_1.1.0.1   
## [65] prettydoc_0.4.1      yaml_2.2.1           colorspace_2.0-0     plotly_4.9.3        
## [69] knitr_1.33           pagedown_0.13