Hi R com.
I have this piece of code:
Distribution of sales pr. salesId
df1 %>%
group_by(ItemId) %>%
mutate(SalesAmount = SalesPrice*SalesQty) %>%
summarize(sum_sale = sum(SalesAmount, na.rm = TRUE)) %>%
ggplot() +
geom_bar(aes(x = reorder(ItemId, sum_sale, FUN = desc),
y = sum_sale), stat = "identity") +
theme_bw() +
xlab("ItemID") +
ylab("Sum Sales")
But i have like 1000+ products and all i want is to look at the top 10 ItemId, the reorder function is not really helping me here unless there is a cool way of taking the top 10 Itemid based on SalesAmount and sort them. Any ideas?