library(readxl)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
your_data <- readxl::read_excel("bike_orderlines.xlsx")
result <- your_data %>%
group_by(bikeshop_name) %>%
summarise(
total_quantity = sum(quantity),
total_percentage = sum(quantity) / sum(your_data$quantity) * 100
)
print(result)
## # A tibble: 30 × 3
## bikeshop_name total_quantity total_percentage
## <chr> <dbl> <dbl>
## 1 Albuquerque Cycles 286 1.42
## 2 Ann Arbor Speed 602 2.98
## 3 Austin Cruisers 246 1.22
## 4 Cincinnati Speed 391 1.94
## 5 Columbus Race Equipment 394 1.95
## 6 Dallas Cycles 234 1.16
## 7 Denver Bike Shop 2301 11.4
## 8 Detroit Cycles 504 2.50
## 9 Indianapolis Velocipedes 319 1.58
## 10 Ithaca Mountain Climbers 1264 6.27
## # ℹ 20 more rows