Nothing
test_that("adjusted_boxplot returns statistics and plots", {
df <- data.frame(normal = stats::rnorm(100), skewed = stats::rexp(100, 0.5))
res <- adjusted_boxplot(df, plot = FALSE)
expect_named(res, c("stats", "outliers"))
expect_equal(nrow(res$stats), 2)
expect_equal(res$stats$median, unname(sapply(df, stats::median)))
expect_s3_class(adjusted_boxplot(df), "ggplot")
})
test_that("adjusted_boxplot validates its inputs", {
test_data <- data.frame(a = stats::rnorm(20))
expect_error(adjusted_boxplot(), "Missing 'x' argument.")
expect_error(adjusted_boxplot(data.frame(test = c("m", "t", "w", 1, 2, 3))), "Input 'x' must be a numeric data frame.")
expect_error(adjusted_boxplot(test_data, plot = 1), "Argument 'plot' must be of type boolean \\(TRUE or FALSE\\).")
expect_error(adjusted_boxplot(test_data, notch = 1), "Argument 'notch' must be of type boolean \\(TRUE or FALSE\\).")
expect_error(adjusted_boxplot(test_data, x_labels_angle = 370), "'x_labels_angle' must be a numeric value between 0 and 360.")
expect_error(adjusted_boxplot(test_data, box_width = 0), "Argument 'box_width' must be a positive numeric value.")
expect_error(adjusted_boxplot(test_data, notch_width = 1.5), "Argument 'notch_width' must be a numeric value between 0 and 1.")
expect_error(adjusted_boxplot(test_data, staple_width = -0.5), "Argument 'staple_width' must be a positive numeric value.")
expect_error(adjusted_boxplot(test_data, fill = "nocolor"), "fill")
expect_error(adjusted_boxplot(test_data, caption = 1), "caption")
expect_error(adjusted_boxplot(test_data, points = "some"), "should be one of")
expect_error(adjusted_boxplot(test_data, id = zz), "'id' column does not exist")
expect_error(adjusted_boxplot(data.frame(a = c(-1, 1, 2, 3, 4)), log = TRUE), "positive")
# the former argument names still work, with a deprecation warning
lifecycle::expect_deprecated(adjusted_boxplot(test_data, box.width = 0.3))
rlang::local_options(lifecycle_verbosity = "quiet")
expect_error(adjusted_boxplot(test_data, xlabels.angle = 370), "'xlabels.angle' must be a numeric value between 0 and 360.")
expect_error(adjusted_boxplot(test_data, xlabels.vjust = 1.5), "Argument 'xlabels.vjust' must be a numeric value between 0 and 1.")
expect_error(adjusted_boxplot(test_data, xlabels.hjust = -0.5), "Argument 'xlabels.hjust' must be a numeric value between 0 and 1.")
expect_error(adjusted_boxplot(test_data, box.width = 0), "Argument 'box.width' must be a positive numeric value.")
expect_error(adjusted_boxplot(test_data, notchwidth = 1.5), "Argument 'notchwidth' must be a numeric value between 0 and 1.")
expect_error(adjusted_boxplot(test_data, staplewidth = -0.5), "Argument 'staplewidth' must be a positive numeric value.")
p <- adjusted_boxplot(test_data, box.width = 0.3, notchwidth = 0.2, staplewidth = 0.1)
box <- ggplot2::ggplot_build(p)$data[[1]]
expect_equal(box$xmax - box$xmin, 0.3)
expect_equal(p$layers[[1]]$geom_params$notchwidth, 0.2)
expect_equal(p$layers[[1]]$geom_params$staplewidth, 0.1)
})
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.