library(knitr)
library(magrittr)
library(reactable)
library(ggplot2)

knitr::opts_chunk$set(echo = TRUE, message = FALSE)

##### Set default print options for data.frame/reactable #####

# register the default methods for print dfs/reactable
registerS3method("knit_print", "data.frame", Rmdplate::knit_print_df)
registerS3method("knit_print", "reactable", Rmdplate::knit_print_reactable)

##### Set defaults for ggplots #####

old_theme <- theme_set(ggpubr::theme_pubr())

Aim: What's the major aim of this .Rmd?



Something useful hopefully! {.tabset}

Tables

Cross-referencing of tables is as yet not available for reactable (https://github.com/glin/reactable/issues/15). Therefore, I've attempted a workaround based off https://cran.r-project.org/web/packages/knitr/vignettes/knit_print.html. To use this, you need to add a fig.cap to the table in the format 'fig.cap = "key: table caption"', then refer the table with \@ref(tab:key) - for example \@ref(tab:iris-table).

iris_10 <- data.frame(iris[1:10,]) 

iris_10

Making sure this also works for reactables \@ref(tab:iris-reactable).

iris_10



Figures

For figures, need to make sure your keys don't have a "_" in them and have fig.cap = "figure caption" to refer to them in the text (\@ref(fig:iris-figure))

iris_10 %>% 
    ggplot(aes(x = Sepal.Length,
               y = Sepal.Width)
    ) +
    geom_point()



Session info

Show/hide

library("sessioninfo")

options(width = 120)

session_info()



dzhang32/Rmdplate documentation built on Sept. 20, 2021, 1:28 a.m.