library(dplyr) library(ggplot2) library(magrittr)

shop_revenue <- bikeshops %>% dplyr::group_by(bikeshops.name) %>% dplyr::summarize(total_revenue = sum(revenue, na.rm = TRUE)) %>% dplyr::arrange(desc(total_revenue))

top_10 <- head(shop_revenue, 10)

other_shops <- shop_revenue %>% dplyr::anti_join(top_10, by = “bikeshops.name”) %>% dplyr::summarize(bikeshops.name = “Other bikeshops”, total_revenue = sum(total_revenue))

combined_data <- bind_rows(top_10, other_shops)

ggplot(combined_data, aes(x = fct_reorder(bikeshops.name, total_revenue), y = total_revenue)) + geom_bar(stat = “identity”, fill = “skyblue”) + coord_flip() +
labs(title = “Top 10 Bikeshop Names by Revenue”, x = “Bikeshop Names”, y = “Total Revenue”)