R/utils.R

Defines functions merge_list write_yaml relative_to_wd

relative_to_wd <- function(path) {
  relative_to(getwd(), path)
}

#' @importFrom yaml write_yaml
write_yaml <- function(x, file) {
  handlers <- list(
    # Handle yes/no from 1.1 to 1.2
    # https://github.com/vubiostat/r-yaml/issues/131
    logical = function(x) {
      value <- ifelse(x, "true", "false")
      structure(value, class = "verbatim")
    }
  )
  yaml::write_yaml(x, file, handlers = handlers)
}


# inline knitr:::merge_list()
merge_list <- function(x, y) {
  x[names(y)] <- y
  x
}

Try the quarto package in your browser

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

quarto documentation built on May 29, 2024, 5:31 a.m.