May you please help me how to generate a bar chart with 4 groups like the picture?
Asked
Active
Viewed 45 times
0

Ali J.
- 47
- 4
-
Possible duplicate of [Simplest way to do grouped barplot](https://stackoverflow.com/questions/17721126/simplest-way-to-do-grouped-barplot) – cropgen Apr 09 '19 at 19:02
1 Answers
0
No data was provided, so I created a dummy data. I created a use case below, otherwise there are get solutions on SO, such as Simplest way to do grouped barplot.
library(tidyverse)
# Data
trees <- data.frame(age = sample(c("Old", "Adult", "Young"),
size = 20, replace = TRUE, prob = c(.5, .25, .25)),
tree = factor(sample(1:5, size = 20, replace = TRUE)),
circumference = rnorm(n = 20, mean = 60, sd = 15))
trees %>%
ggplot(aes(x = age, y = circumference, fill = tree)) +
geom_col(position = "dodge") +
coord_flip()

OTStats
- 1,820
- 1
- 13
- 22