File: test-ggplot-col.R

package info (click to toggle)
r-cran-plotly 4.10.4%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 30,636 kB
  • sloc: javascript: 195,272; sh: 24; makefile: 6
file content (19 lines) | stat: -rw-r--r-- 593 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19


# https://gist.github.com/jsonbecker/0cc702804512fdf29c7f9067adfc17d0#gistcomment-1935427
df <- data.frame(
  type = c(rep('Elementary', 2), rep('Middle', 2), rep('High', 2)),
  included = rep(c('included','excluded'), 3),
  dollars = c(1000, 2500, 4000, 1000, 3000, 2800)
)

p <- df %>% 
  group_by(type) %>% 
  mutate(prop = dollars / sum(dollars)) %>% 
  ggplot(aes(type, prop, fill = included)) + 
  geom_col() +
  geom_text(aes(label = scales::percent(prop)), position = position_stack(vjust = 0.5))  

test_that("geom_col is supported", {
  l <- expect_doppelganger_built(p, "col")
})