Good afternoon,
I am trying to create some plots within R Studio from the following data:
structure(list(Transaction = c(1L, 2L, 2L, 3L, 3L, 3L), Item = c("Bread",
"Scandinavian", "Scandinavian", "Hot chocolate", "Jam", "Cookies"
), period_day = c("morning", "morning", "morning", "morning",
"morning", "morning"), weekday_weekend = c("weekend", "weekend",
"weekend", "weekend", "weekend", "weekend"), Month = c("October",
"October", "October", "October", "October", "October"), Time = c("09",
"10", "10", "10", "10", "10")), row.names = c(NA, 6L), class = "data.frame")
I am trying to create bar charts to explore the data visually, for instance, I would like to plot:
- Transactions per Month.
- Transactions per Time of Day (Morning, Afternoon, Evening and Night).
- Transactions per Hour of Day (01, 02, 03, etc.).
- Transactions per Weekday/Weekend.
For example:
This kind of plot, with different colours for the different months.
How can I start to produce these plots? I have tried the following code:
SalesByTime <- bb_raw %>%
group_by(Time, Item) %>%
summarise(Transactions = sum(Item))
But I believe this was taking the sum of the transaction numbers, not the frequency of the sales (see below).
structure(list(Time = c("01", "07", "08", "09", "10", "11", "12",
"13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"
), Transactions = c(4090L, 59889L, 3143112L, 9168556L, 12679593L,
15159832L, 14129139L, 13231165L, 13633823L, 11081386L, 7053231L,
1969450L, 289382L, 223385L, 104967L, 16411L, 76746L, 22825L)), row.names = c(NA,
-18L), class = c("tbl_df", "tbl", "data.frame"))
Any suggestions? Any help would be massively appreciated. Please let me know if there's any more information I can provide.
question from:
https://stackoverflow.com/questions/65646004/creating-plots-of-my-transactions-within-r-studio