R/bcat_setup_rmd.R

Defines functions bcat_setup_rmd

Documented in bcat_setup_rmd

#' Defaults for Rmd Setup Chunk
#'
#' Sets default code chunk options and configures options for kable tables.
#' Call at the start of Rmd file in "setup" chunk.
#'
#' @return No return value, called for side effects on knitr chunk defaults and
#'   table-related options.
#'
#' @author Saannidhya Rawat
#' @family utilities
#' @export
#'
#' @examples
#' \donttest{
#' # Call in your Rmd setup chunk:
#' bcat_setup_rmd()
#' }
bcat_setup_rmd <- function(){

  # use ragg_png for graphics
  if (!knitr::is_latex_output()){

    knitr::opts_chunk$set(dev = "ragg_png")

  }

  # default options for chunks
  knitr::opts_chunk$set(echo = FALSE,
                        warning = FALSE,
                        message = FALSE,
                        fig.align = "center",
                        dpi = 300,
                        fig.width = 6,
                        fig.asp = 0.618,
                        out.width = "70%",
                        fig.pos = "H",
                        comment = NA)

  # kable options
  options(knitr.kable.NA = '')
  options(kableExtra.html.bsTable = TRUE)

  invisible(NULL)

}

Try the Rbearcat package in your browser

Any scripts or data that you put into this service are public.

Rbearcat documentation built on March 21, 2026, 5:07 p.m.