#class_11.28
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
path_bike_orderlines <- "bike_orderlines.rds"
bike_orderlines_tbl <- readRDS(path_bike_orderlines)
grouped_data <- bike_orderlines_tbl %>%
group_by(bikeshop_name) %>%
summarise(total_quantity = sum(quantity), count = n()) %>%
mutate(percentage = (total_quantity / sum(total_quantity)) * 100)
print(grouped_data)
## # A tibble: 30 × 4
## bikeshop_name total_quantity count percentage
## <chr> <dbl> <int> <dbl>
## 1 Albuquerque Cycles 286 207 1.42
## 2 Ann Arbor Speed 602 461 2.98
## 3 Austin Cruisers 246 192 1.22
## 4 Cincinnati Speed 391 298 1.94
## 5 Columbus Race Equipment 394 296 1.95
## 6 Dallas Cycles 234 182 1.16
## 7 Denver Bike Shop 2301 1801 11.4
## 8 Detroit Cycles 504 373 2.50
## 9 Indianapolis Velocipedes 319 231 1.58
## 10 Ithaca Mountain Climbers 1264 975 6.27
## # ℹ 20 more rows
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE
parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.