tests/testthat/test-compute-boxplot.r

context("compute_boxplot")

test_that("Zero-row inputs", {
  res <- mtcars[0,] %>% compute_boxplot(~mpg)
  expect_equal(nrow(res), 0)
  expect_true(setequal(
    names(res),
    c("min_", "lower_", "median_", "upper_", "max_", "outliers_")
  ))
  expect_identical(res$outliers_, list())

  # Grouped
  res <- mtcars %>% group_by(cyl) %>% dplyr::filter(FALSE) %>% compute_boxplot(~mpg)
  expect_equal(nrow(res), 0)
  expect_true(setequal(
    names(res),
    c("cyl", "min_", "lower_", "median_", "upper_", "max_", "outliers_")
  ))
  expect_identical(res$outliers_, list())
})

Try the ggvis package in your browser

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

ggvis documentation built on May 29, 2024, 1:12 a.m.