tests/testthat/test-facet.R

# Data preparation
data("ToothGrowth")
df <- ToothGrowth
# Adding column name with space
df[['spa ced']] <- df[['supp']]


test_that("facet works", {
  p <- ggpubr::ggboxplot(df, "dose", "len", facet.by = "supp")
  panels <- ggplot2::layer_data(p)[["PANEL"]] %>%
    unique() %>%
    as.numeric()
  expect_equal(panels, c(1, 2))
})


test_that("facet works when column names contain space", {
  p <- ggpubr::ggboxplot(df, "dose", "len", facet.by = "spa ced")
  panels <- ggplot2::layer_data(p)[["PANEL"]] %>%
    unique() %>%
    as.numeric()
  expect_equal(panels, c(1, 2))
})

Try the ggpubr package in your browser

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

ggpubr documentation built on Feb. 16, 2023, 7:18 p.m.