Reputation: 146
I have a data frame like this:
app_id <- seq(1,10,1)
approved <- c(0,1,1,2,1,0,1,2,1,0)
week <- as.Date(c('2019-11-18','2019-11-18','2019-11-18','2019-11-25','2019-12-02','2019-12-02','2019-12-09','2019-12-09','2019-12-09','2019-12-09'))
data <- data.frame(app_id,approved,week)
I would like to have a stacked barchart with week
on x axis and count of app_id
on y axis stacked by approved
(so 3 colors)
How do I do that? Many thanks!
Upvotes: 1
Views: 98
Reputation: 8127
data %>%
group_by(approved, week) %>%
summarise(aggValue = n()) %>%
ggplot(aes(week, aggValue, fill = factor(approved))) +
geom_bar(stat = "identity")
Upvotes: 1