tests/testthat/helper.R

#' Returns a character vector of the geoms of a ggplot2 plot
#'
#' Taken from: https://bit.ly/2B7TzEw (shortened)
#'
#' @param p a ggplot2 plot
get_geoms <- function(p) {
  sapply(p$layers, function(x) class(x$geom)[1])
}

#' Returns the number of facets of a ggplot2 plot
#'
#' Taken from: https://bit.ly/2UriIB4 (shortened)
#'
#' @param p a ggplot2 plot
get_facet_dim <- function(p) {
  length(unique(ggplot2::ggplot_build(p)$data[[1]]$PANEL))
}

# Taken from greta.
expect_ok <- function(expr) {
  expect_error(expr, NA)
}

Try the rater package in your browser

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

rater documentation built on Sept. 12, 2023, 1:13 a.m.