R/check_dims.R

Defines functions check_dims

Documented in check_dims

#' Check that tibble has expected dimensions.
#'
#' @param data A tibble or data frame.
#' @param expected_rows Expected number of rows of tibble.
#' @param expected_cols Expected number of columns of tibble.
#'
#' @export
#'
#' @examples
#'
#' check_dims(iris, expected_rows = 150)
#'
check_dims <- function(data, expected_rows = NULL, expected_cols = NULL) {

  if (!is.null(expected_rows)) {
    expect_equal(nrow(data), expected_rows)
  }

  if (!is.null(expected_cols)) {
    expect_equal(ncol(data), expected_cols)
  }
}

Try the modeltests package in your browser

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

modeltests documentation built on Jan. 16, 2021, 5:38 p.m.