r - How to create a "gap" in a barplot? -
how achieve "gap" in barplot, this:
i tried create empty column in contingency table, couldn't.
sample data:
groups = c("a", "b") choices = c("orange", "apple", "beer") dat <- data.frame( group = rep(groups, c(93, 94)), choice = factor(c( rep(choices, c(51, 30, 12)), rep(choices, c(47, 29, 18)) ), levels = choices ) ) barplot(table(dat), beside = true)
you can achieve with:
barplot(table(dat), beside = true, space = c(0, 0, 1.5, 0, 3, 0))
the logic space
values fiddly:
- you don't need space before first bar- first value 0
- you don't need space between first , second bars (the 2 "orange" bars)
- you need standard amount of space before first bar of "apple"
- you need space before first "beer" bar
result:
Comments
Post a Comment