tests/testthat/test_wheat_plot.R

test_that("wheat_plot returns a ggplot", {
  set.seed(42)
  df <- data.frame(value = rnorm(200, mean = 50, sd = 10))
  p <- suppressWarnings(wheat_plot(df, value, binwidth = 2))
  expect_s3_class(p, "ggplot")
})

test_that("wheat_plot chooses a binwidth automatically", {
  set.seed(1)
  df <- data.frame(value = rnorm(100))
  p <- suppressWarnings(wheat_plot(df, value))
  expect_s3_class(p, "ggplot")
  # one point per observation
  expect_equal(nrow(p$data), nrow(df))
})

test_that("wheat_plot works on taxa_sums of a phyloseq object", {
  df <- data.frame(value = taxa_sums(data_fungi_mini))
  p <- suppressWarnings(wheat_plot(df, value, binwidth = 2000))
  expect_s3_class(p, "ggplot")
})

test_that("wheat_plot errors on a non-numeric column", {
  df <- data.frame(value = letters[1:10])
  expect_error(suppressWarnings(wheat_plot(df, value)), "numeric")
})

Try the MiscMetabar package in your browser

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

MiscMetabar documentation built on Nov. 16, 2026, 5:06 p.m.