R Markdown

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:

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.3     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.3     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(lubridate)

bike_data <- read_rds("C:/Users/daavka/Downloads/bike_orderlines (1).rds")

bike_data <- bike_data %>%
  mutate(model = case_when(
    model == "CAAD Disk Ultegra" ~ "CAAD12 Disc Ultegra",
    model == "Syapse Carbon Tiagra" ~ "Synapse Carbon Tiagra",
    model == "Supersix Evo Hi-Mod Utegra" ~ "Supersix Evo Hi-Mod Ultegra"
  ))
library(tidyverse)

highest_sales_month <- bike_data %>%
  mutate(Month = month(order_date, label = TRUE)) %>%
  group_by(Month) %>%
  summarise(Sales = sum(total_price)) %>%
  arrange(desc(Sales)) %>%
  slice(1)

median_orderline_black_inc <- bike_data %>%
  group_by(`Black Inc` = model == "Black Inc") %>%
  summarise(`Median Orderline` = median(order_line))

median_orderline_ultegra <- bike_data %>%
  group_by(Ultegra = model == "Ultegra") %>%
  summarise(`Median Orderline` = median(order_line))

median_orderline_disc <- bike_data %>%
  group_by(Disc = model == "Disc") %>%
  summarise(`Median Orderline` = median(order_line))

price_stats <- bike_data %>%
  group_by(category_1, category_2, `Model Base` = model) %>%
  summarise(
    `Mean Price` = mean(price),
    `Min Price` = min(price),
    `Max Price` = max(price),
    .groups = "drop"
  )
print(highest_sales_month)
## # A tibble: 1 × 2
##   Month     Sales
##   <ord>     <dbl>
## 1 4-р сар 8386170
print(median_orderline_black_inc)
## # A tibble: 2 × 2
##   `Black Inc` `Median Orderline`
##   <lgl>                    <dbl>
## 1 FALSE                        7
## 2 NA                           7
print(median_orderline_ultegra)
## # A tibble: 2 × 2
##   Ultegra `Median Orderline`
##   <lgl>                <dbl>
## 1 FALSE                    7
## 2 NA                       7
print(median_orderline_disc)
## # A tibble: 2 × 2
##   Disc  `Median Orderline`
##   <lgl>              <dbl>
## 1 FALSE                  7
## 2 NA                     7
print(price_stats)
## # A tibble: 11 × 6
##    category_1 category_2       `Model Base` `Mean Price` `Min Price` `Max Price`
##    <chr>      <chr>            <chr>               <dbl>       <dbl>       <dbl>
##  1 Mountain   Cross Country R… <NA>                5267.        1840       12790
##  2 Mountain   Fat Bike         <NA>                2767.        2130        3730
##  3 Mountain   Over Mountain    <NA>                5005.        3200        8200
##  4 Mountain   Sport            <NA>                 894.         415        1520
##  5 Mountain   Trail            <NA>                3644.        1620       12250
##  6 Road       Cyclocross       <NA>                2339.        1750        3500
##  7 Road       Elite Road       Supersix Ev…        4260         4260        4260
##  8 Road       Elite Road       <NA>                3402.         815       12790
##  9 Road       Endurance Road   Synapse Car…        1840         1840        1840
## 10 Road       Endurance Road   <NA>                3168.         870        9590
## 11 Road       Triathalon       <NA>                3527.        1950        7000

Including Plots

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.