tests/testthat/test-stat_prop.R

test_that("stat_prop works as expected", {
  df <- as.data.frame(Titanic)
  p <- ggplot(df) +
    aes(x = Class, fill = Survived, weight = Freq, by = Class) +
    geom_bar(position = "fill")
  result <- expect_silent(
    p + geom_text(stat = "prop", position = position_fill(.5))
  )
  expect_s3_class(result, "ggplot")
})

Try the ggplot2.utils package in your browser

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

ggplot2.utils documentation built on June 26, 2024, 1:06 a.m.