showcase-your-research

CES Skills Seminars

José R. Ferrer-Paris
(a.k.a. Jose Ferrer; JR)

2024-09-20

Reproducible research

In CES Skills seminars:

Typical workflow

From code to presentation / report / manuscript:

Can we make this reproducible?

Yes!

In three (or so) easy steps

Step 1:

Write reproducible code that creates what you want to show (tables, figures, maps, etc.)

library(ggplot2)
library(cowplot)
library(magick)

yes_img <- here::here("images/yes.png")
no_img <- here::here("images/no.png")

yes_plot <- ggdraw() + draw_image(yes_img, scale = 1)
no_plot <- ggdraw() + draw_image(no_img, scale = 1)

bad_plot <- 
  ggplot(mpg, aes(x = displ, y = hwy, colour = "blue")) +
  geom_point()

good_plot <- 
  ggplot(mpg, aes(x = displ, y = hwy)) +
  geom_point(colour = "blue") +
  geom_smooth(colour = "red") + 
  theme_half_open(12) +
  labs(x = "Engine power (litres displ.)",
       y = "Fuel Efficiency (miles/gallon)")

plot_grid(yes_plot, good_plot,
          no_plot, bad_plot) 

Step 2:

Choose your tool to combine text and code and create beautiful documents.

LaTeX logo       Markdown-mark       quarto logo       Jupyter logo       reveal.js

Step 2 and a half:

On top of that, there are many libraries that help making your code reactive and interactive (if you want to):

Plotly-logo       observable       leaflet js logo       Shiny logo

Step 3

Use and reuse your code in:

  • presentations,
  • reports,
  • manuscripts,
  • webpages,
  • dashboards,
  • blog posts,
  • webapps, etc

Examples

  • In this seminar using :
    • Rmarkdown + knitr
    • quarto + knitr
    • quarto + jupyter

More examples

  • Quarto project: HTML / pre-print /
  • My blog with code HTML /
  • Markdown dashboard: /
  • Blogdown website: /

This presentation was prepared by:

José R. Ferrer-Paris ( 0000-0002-9554-3395 / @jrfep)

and is shared with license: Atribution 4.0 Internacional ( 4.0)

This presentation is available at:

jrfep.quarto.pub/showcase-your-research

This presentation was created using RStudio, Quarto v.1.5.57 with fontawesome extension, and reveal.js.

Original content, code and instructions available at: UNSW-codeRs/showcase-your-research

Background images from my iNaturalists observations:

Other images attributed in the slide text or source code.

R version 4.3.1 (2023-06-16)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.7

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8

time zone: Australia/Sydney
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] magick_2.8.1  cowplot_1.1.1 ggplot2_3.5.0

loaded via a namespace (and not attached):
 [1] Matrix_1.6-4     gtable_0.3.4     jsonlite_1.8.8   dplyr_1.1.4     
 [5] compiler_4.3.1   tidyselect_1.2.1 Rcpp_1.0.13      splines_4.3.1   
 [9] scales_1.3.0     yaml_2.3.8       fastmap_1.1.1    lattice_0.22-5  
[13] here_1.0.1       R6_2.5.1         labeling_0.4.3   generics_0.1.3  
[17] knitr_1.45       tibble_3.2.1     munsell_0.5.0    rprojroot_2.0.4 
[21] pillar_1.9.0     rlang_1.1.4      utf8_1.2.4       xfun_0.41       
[25] cli_3.6.3        withr_3.0.1      magrittr_2.0.3   mgcv_1.9-0      
[29] digest_0.6.33    grid_4.3.1       lifecycle_1.0.4  nlme_3.1-164    
[33] vctrs_0.6.5      evaluate_0.23    glue_1.7.0       farver_2.1.1    
[37] fansi_1.0.6      colorspace_2.1-0 rmarkdown_2.25   tools_4.3.1     
[41] pkgconfig_2.0.3  htmltools_0.5.7