this is the nav!
Workspace
Joshua Wright/

# Analysis of Motorcycle Sales Data

0
Beta

#Analysis of Total Sales and Average Price per Unit from June 1, 2021 to August 28, 2021

#### .mfe-app-workspace-kj242g{position:absolute;top:-8px;}.mfe-app-workspace-11ezf91{display:inline-block;}.mfe-app-workspace-11ezf91:hover .Anchor__copyLink{visibility:visible;}Loads necessary libraries, loads data, and displays first six rows.

```.mfe-app-workspace-qcdhrn{font-size:13px;line-height:1.5384615384615385;font-family:JetBrainsMonoNL,Menlo,Monaco,'Courier New',monospace;}```library(tidyverse)
library(lubridate)
df <- readr::read_csv('./data/sales_data.csv')
head(df)``````

#### Calculates and visualizes total sales for each payment method.

1. What are the total sales for each payment method?
``````df %>%
group_by(payment) %>%
summarize(total_sales = sum(total))

df %>%
mutate(payment = factor(payment, levels=c("Cash", "Credit card", "Transfer"))) %>%
ggplot(aes(x = payment, y = total)) +
geom_col() +
labs(title = "Total Sales by Payment Method", x = "Payment Method", y = "Total Sales (USD)", caption = "Total Sales of \$289113") +
scale_y_continuous(labels = scales::dollar) +
theme_bw()``````

#### Calculates and visualizes average unit price for each product line.

1. What is the average unit price for each product line?
``````df %>%
group_by(product_line) %>%
summarize(avg_unit_price = mean(unit_price))

df %>%
mutate(product_line = factor(product_line, levels=c("Breaking system", "Miscellaneous", "Electrical system",
"Suspension & traction", "Frame & body", "Engine"))) %>%
ggplot(aes(x = product_line, y = unit_price)) +
geom_bar(stat = "summary", fun = "mean") +
labs(title = "Average Unit Price by Product Line", x = "Product Line", y = "Average Unit Price (USD)") +
scale_y_continuous(labels = scales::dollar) +
theme_bw() +
coord_flip()``````
1. [Optional] Investigate further (e.g., average purchase value by client type, total purchase value by product line, etc.)

###Calculates and visualizes total sales across June, July, and August by client type.

``````df %>%
mutate(month_of_year = month(date)) %>%
group_by(month_of_year) %>%
summarize(total_sales = sum(total)) %>%
ungroup()

df %>%
mutate(month_of_year = month(date)) %>%
group_by(month_of_year, client_type) %>%
summarize(total_sales = sum(total)) %>%
ungroup()

df %>%
group_by(client_type) %>%
summarize(total_sales = sum(total)) %>%
ungroup()

df %>%
mutate(month_of_year = month(date)) %>%
ggplot(aes(x = month_of_year, y = total)) +
geom_col() +
labs(title = "Total Sales by Month and Client Type", x = "Month", y = "Total Sales (USD)") +
scale_y_continuous(labels = scales::dollar) +
theme_bw() +
facet_wrap(~ client_type)``````
1. Summarize your findings.

###Summary of Analysis

Based upon this analysis, total sales from June 1, 2021 to August 28, 2021 were 289113. Payments were predominantly made through transfer (159642.30) and credit cards (110271.60), with the remainder through cash (19199.10). The Engine product line had the highest average price per unit at 60.09, while the breaking system product line had the lowest average price per unit at 17.74. Sales in June were 95320.03, which declined in July (93547.91) and the highest sales occurred in August (100245.06). Sales were higher in the Wholesale category (159642.30) relative to the retail category (129470.70) but the pattern of sales differed within these categories from June 1, 2021 to August 28, 2021. Total sales in the retail category declined from June (42220.15) to July (44461.80) to August (38788.72). In contrast, total sales in the wholesale category remained the same from June (49099.88) to July (49086.11), before increasing in August (\$61456.43).