knit_print_df: Automatically print data.frames as reactable html widget

Description Usage Arguments Value Examples

View source: R/knit_print.R

Description

This is intended to replace the default knitr printing method for data.frame objects and is used in the "rmd_template_dz" to automatically render data.frames as reactables. This also adds a caption to enable the a workaround to allow table cross-referencing in the .Rmd using \@ref(tab:KEY). The solution uses htmltools to manually add a caption inputted through the chunk option fig.cap and was inspired from https://github.com/glin/reactable/issues/15.

Usage

1

Arguments

df

a data.frame

options

this will be taken as a list of a parameters inputted into the chunk. Specifically, the fig.cap chunk parameter is used to input to label tables with a caption enabling referencing them in the text.

...

Included based off this tutorial https://cran.r-project.org/web/packages/knitr/vignettes/knit_print.html. Required for knitr::knit_print.

Value

reactable html widget with a caption.

Examples

1
2
3
4
5
6
## Not run: 
# add this line to the setup chunk of your .Rmd
# to overwrite the existing method for printing data.frames
registerS3method("knit_print", "data.frame", Rmdplate::knit_print.data.frame)

## End(Not run)

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