#(comeback to this later)
install.packages("tidyverse")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.3'
## (as 'lib' is unspecified)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.0 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ 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
df <- read_csv("Class Playlist Clean DS4 - Sheet1.csv")
## Rows: 175 Columns: 3
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): Genre, Artist, Song
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
head(df)
## # A tibble: 6 × 3
## Genre Artist Song
## <chr> <chr> <chr>
## 1 Genre 1 - hiphop/rap 8k When you call
## 2 Genre 2 - pop/kpop/Latin Yonaguni bad bunny
## 3 Genre 1 - hiphop/rap $uicideboy$ Diemonds
## 4 Genre 1 - hiphop/rap $uicideboy$ Not Even Ghosts Are This Empty
## 5 Genre 1 - hiphop/rap 03 Greedo Trap House
## 6 Genre 5 - alt/indie/folk 10,000 Maniacs Trouble Me
df$Genre <- as.factor(df$Genre)
df %>% count(Genre)
## # A tibble: 6 × 2
## Genre n
## <fct> <int>
## 1 Genre 1 - hiphop/rap 58
## 2 Genre 2 - pop/kpop/Latin 25
## 3 Genre 3 - house/ska 5
## 4 Genre 4 - rnb/soul 14
## 5 Genre 5 - alt/indie/folk 45
## 6 Genre 6 - country/rock 28
Genre_counts <- df %>% count(Genre)
Genre_counts <- Genre_counts %>% mutate(prob = n/sum(n))
Genre_counts
## # A tibble: 6 × 3
## Genre n prob
## <fct> <int> <dbl>
## 1 Genre 1 - hiphop/rap 58 0.331
## 2 Genre 2 - pop/kpop/Latin 25 0.143
## 3 Genre 3 - house/ska 5 0.0286
## 4 Genre 4 - rnb/soul 14 0.08
## 5 Genre 5 - alt/indie/folk 45 0.257
## 6 Genre 6 - country/rock 28 0.16
Genre_counts$prob <- round(Genre_counts$prob, 2)
Genre_counts
## # A tibble: 6 × 3
## Genre n prob
## <fct> <int> <dbl>
## 1 Genre 1 - hiphop/rap 58 0.33
## 2 Genre 2 - pop/kpop/Latin 25 0.14
## 3 Genre 3 - house/ska 5 0.03
## 4 Genre 4 - rnb/soul 14 0.08
## 5 Genre 5 - alt/indie/folk 45 0.26
## 6 Genre 6 - country/rock 28 0.16
sample <- sample_n(df, 50)
sample
## # A tibble: 50 × 3
## Genre Artist Song
## <fct> <chr> <chr>
## 1 Genre 6 - country/rock Paul Simon Run That Body Down
## 2 Genre 4 - rnb/soul Blood Orange Alien Love Call
## 3 Genre 1 - hiphop/rap Young Slo-Be Fun Fakt
## 4 Genre 5 - alt/indie/folk 10,000 Maniacs Trouble Me
## 5 Genre 6 - country/rock Coyote Kisses Six Shooter
## 6 Genre 5 - alt/indie/folk cage the elephant cigarette day dream
## 7 Genre 1 - hiphop/rap $uicideboy$ Not Even Ghosts Are This Empty
## 8 Genre 1 - hiphop/rap Stone ii O.T.W
## 9 Genre 6 - country/rock KMFDM Stray Bullet
## 10 Genre 1 - hiphop/rap 50 cent 21 questions
## # ℹ 40 more rows
#yes, the genres do repersent as genre 1 was the most popular and that showed up in the lists that i looked at
#the way the simualtion helped answer the question was by shuffling the songs with the genres from the class playlist
#you could use the simuation to calculate the probality of other things
#the most challengingpice of code was the one that counted the differnt genres, it’s also the one im mosy proud of because it was so hard
#i wouldn;t do anything differntly