# one grouping factor
df <- data.frame(
outcome = c(3, 4, 5, 2, 4, 6, 5, 7, 8),
group = factor(c("a", "a", "a", "b", "b", "b", "c", "c", "c"))
)
bars(outcome ~ group, data = df)
# two grouping factors
df2 <- data.frame(
outcome = c(3, 4, 5, 2, 4, 6, 5, 7, 8, 4, 3, 6),
group1 = factor(rep(c("a", "b"), each = 6)),
group2 = factor(rep(c("x", "y", "z"), times = 4))
)
bars(outcome ~ group1 + group2, data = df2)
Run the code above in your browser using DataLab