HW 05 - Legos

Elijah Adelegan 10-18-2024

Load packages and data

#install.packages("tidyverse")
library(tidyverse)
load("data/lego_sales.rda")

Exercises

Exercise 1

lego_sales |> count(first_name, sort = TRUE) |> top_n(10) The 3 most common first names are Jackson, Jacob, and Joseph

Exercise 2

lego_sales |> count(theme, sort = TRUE) |> top_n(10) The 3 most common themes are Star Wars, Nexo Knights, and Gear

Exercise 3

lego_sales |> count(subtheme, sort = TRUE) |> top_n(10) The most commmon subtheme is Episode V Star Wars, Ninjago and Mixels (Series 7)

Exercise 4

lego_sales |> count(age, sort = TRUE) |> top_n(10)

Exercise 5

lego_sales |> count(age, sort = TRUE) |> top_n(10) 26-35

Exercise 6

lego_sales |> count(age, sort = TRUE) |> top_n(10) 26-35, 37-40

Exercise 7

lego_sales |> count(theme, sort = TRUE) |> top_n(10) Star Wars

Exercise 8

lego_sales |> count(phone_number, sort = TRUE) |> top_n(10) 807 is the area code

Exercise 9

A question I have is the most common purchase by age number ggplot(lego_sales, aes(x = us_price)) + geom_histogram(binwidth = 5000) + facet_wrap(~ age) By the graph it is the age 33 with the most purchases, with 38,39,and 40