I have several criteria from which I want to create a stacked barchart.
My criteria are: work week, quantity, customer, Tag (Received, Shipped)
This (facet_grid(~Tag)) looks ok but is not really what I need.
ggplot(allRecords, aes(x = reorder(WW,Date), y = Quantity, fill =
Customer)) +
geom_bar(stat = "identity", position = "fill", colour = "black") +
facet_grid(~Tag) +
labs(x = "Work Week") +
ggtitle("Goods last 3 months by core customers") +
theme_bw()
I need a stacked chart for "received" and "shipped" for each work week by customer.
Some sample rows:
WW <- c(1,1,1,2,2,2,3,3,3)
Quantity <- c(12,23,12,34,56,23,10,11,23)
Date <- lubridate::ymd_hms(c("2019-01-03 10:07:31", "2019-01-03 10:07:31", "2019-01-03 10:07:31", "2019-01-09 15:49:41", "2019-01-09 15:49:4", "2019-01-09 15:49:4", "2019-01-16 09:53:56", "2019-01-16 09:53:56", "2019-01-16 09:53:56"))
Customer <- c("C1", "C2", "Other","C1", "C2", "Other","C1", "C2", "Other")
Tag <- as.factor(c("Received", "Received", "Shipped", "Shipped", "Received", "Received", "Shipped", "Received", "Received"))
records <- data.frame(WW, Quantity, Date, Customer, Tag)