How to plot a performance/ rate graph ? in r


How to plot a performance/ rate graph ? in r



I am trying to plot a graph depicting the performance of the best selling items, moderate selling items and the least selling items and they show which particular brand they belong to and their respective sub_category + category



Raw Data :


sraw <- structure(list(Date = c("2018-02-28", "2018-02-28", "2018-02-28",
"2018-02-28", "2018-02-28", "2018-02-28"), Category = c("Bakery ",
"Household ", "Household ", "Personal care", "Personal care",
"Breakfast "), Sub_Category = c("Wafers ", "laundry ", "Pet Care",
"Womens grooming ", "Womens grooming ", "Instant food"), Product
= c("strawbery",
"washing powder ", "Cat food ", "sanitary pad ", "sanitary pad ",
"Noodles "), Brand = c("NO BRAND", "wheel ", "Whiskars", "whisper",
"whisper", "Yipee"), Day = c(28L, 28L, 28L, 28L, 28L, 28L), Month = c(2L,
2L, 2L, 2L, 2L, 2L), Year = c(2018L, 2018L, 2018L, 2018L, 2018L,
2018L), MRP = c("5", "48", "160", "34", "40", "45"), Quantity = c(2,
1, 1, 1, 1, 1), Sales = c(10, 48, 160, 34, 40, 45), Wday = c("Wednesday",
"Wednesday", "Wednesday", "Wednesday", "Wednesday", "Wednesday"
), Week = c(9L, 9L, 9L, 9L, 9L, 9L), X = c(NA, NA, NA, NA, NA,
NA), X. = c(NA, NA, NA, NA, NA, NA)), .Names = c("Date", "Category",
"Sub_Category", "Product", "Brand", "Day", "Month", "Year", "MRP",
"Quantity", "Sales", "Wday", "Week", "X", "X."), row.names = 870158:870163,
class = "data.frame")



Can anyone please guide me on how I can achieve this ?



MY attempt so far:
First transform the data, call it sraw6 like so


sraw6 <- sraw %>%
group_by(Year,Month,Brand) %>%
summarise_at(vars(Sales,Quantity), sum, na.rm = TRUE) %>%
mutate(Total = Sales)

ggplot(sraw6,aes(sraw6$Month,sraw6$Sales)) + stat_summary(fun.y="mean", geom="bar")

ggplot(sraw6,aes(x=reorder(sraw6$Brand,-
sraw6$Sales),y=sraw6$Sales,fill=sraw6$Brand)) + geom_bar(stat="identity")



Expected output similar to this :
enter image description here



but instead of markets and sales channels it would be : highest selling brand, least selling brand and moderate selling brand



Thanks





It's not clear from your sample data and problem statement what you actually want to plot. The image is way too low-res to identify anything; please clarify, what quantities you want to show (1) on the x and y axis, (2) on the different facets, (3) through different colours. It looks like you're after a bar chart? What have you tried so far? Please share your code!
– Maurits Evers
Jun 29 at 4:55






@MauritsEvers hi there! I have made further edits to the question, kindly check now. As for the problem statement: I need to show 3 graphs - each for a particular segment of the sales ( highest, least and moderate selling brands). On the x -axis it would be date( can be month/week) and Y axis would show sales
– 9minus4
Jun 29 at 11:11










By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Export result set on Dbeaver to CSV

Opening a url is failing in Swift