Skip to content

Commit 2fb00ff

Browse files
committed
demonstrate with a test that we also fixed #424
1 parent a1c70b4 commit 2fb00ff

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/testthat/test-ggplot-errorbar.R

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,22 @@ test_that("geom_errorbar gives errorbars", {
1616
# right data for errorbar ymax
1717
expect_equal(L$data[[1]]$error_y$array, c(3.74, 1.26, 1.15))
1818
})
19+
20+
df <- data.frame(
21+
trt = factor(c(1, 1, 2, 2)),
22+
resp = c(1, 5, 3, 4),
23+
group = factor(c(1, 2, 3, 4)),
24+
upper = c(1.1, 5.3, 3.3, 4.2),
25+
lower = c(0.8, 4.6, 2.4, 3.6)
26+
)
27+
28+
p <- ggplot(df, aes(trt, resp, colour = group))
29+
g <- p + geom_errorbar(aes(ymin = lower, ymax = upper))
30+
31+
test_that("geom_errorbar boxes an array of length 1", {
32+
L <- save_outputs(g, "errorbar-unique-groups")
33+
expect_true(inherits(L$data[[1]]$error_y$array, "AsIs"))
34+
expect_true(inherits(L$data[[1]]$error_y$arrayminus, "AsIs"))
35+
})
36+
37+
# TODO fix and add a test for width of errorbars

0 commit comments

Comments
 (0)