DS4 Song Shuffle

Introduction

come back to this later and fill it out

now I am going to install tidyverse

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

Now I am going to install my data

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
summary(df)
##     Genre              Artist              Song          
##  Length:175         Length:175         Length:175        
##  Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character

#Calculating Experimental Probabilities ##Our next task is to simulate how shuffle works by pulling a random sample of songs and saving it as a new table

sample_counts<-sample_n(df, 10)
sample_counts
## # A tibble: 10 × 3
##    Genre                    Artist        Song                       
##    <chr>                    <chr>         <chr>                      
##  1 Genre 1 - hiphop/rap     Lil Uzi Vert  Erase your social          
##  2 Genre 2 - pop/kpop/Latin Taylor Swift  Style                      
##  3 Genre 5 - alt/indie/folk Novo Amor     Anchor                     
##  4 Genre 6 - country/rock   Hank Williams I'm So Lonesome I Could Cry
##  5 Genre 1 - hiphop/rap     03 Greedo     Trap House                 
##  6 Genre 4 -  rnb/soul      Rihanna       Nobody's Business          
##  7 Genre 2 - pop/kpop/Latin Phantogram    Fall In Love               
##  8 Genre 1 - hiphop/rap     Drake         Scholarships               
##  9 Genre 2 - pop/kpop/Latin bad bunny     kpop                       
## 10 Genre 1 - hiphop/rap     B.o.B         Airplanes

#Now I will adjust this table to show me just the genres and their probabilities

genre_counts<-df%>%count(df$Genre)
genre_counts
## # A tibble: 6 × 2
##   `df$Genre`                   n
##   <chr>                    <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
sample_n(df, 30) %>% count(Genre) %>% mutate(probability = round(n/sum(n), 2))
## # A tibble: 6 × 3
##   Genre                        n probability
##   <chr>                    <int>       <dbl>
## 1 Genre 1 - hiphop/rap         7        0.23
## 2 Genre 2 - pop/kpop/Latin     3        0.1 
## 3 Genre 3 -  house/ska         1        0.03
## 4 Genre 4 -  rnb/soul          4        0.13
## 5 Genre 5 - alt/indie/folk     7        0.23
## 6 Genre 6 - country/rock       8        0.27
sample_n(df, 40) %>% count(Genre) %>% mutate(probability = round(n/sum(n), 2))
## # A tibble: 6 × 3
##   Genre                        n probability
##   <chr>                    <int>       <dbl>
## 1 Genre 1 - hiphop/rap        16        0.4 
## 2 Genre 2 - pop/kpop/Latin     8        0.2 
## 3 Genre 3 -  house/ska         1        0.03
## 4 Genre 4 -  rnb/soul          1        0.03
## 5 Genre 5 - alt/indie/folk     7        0.17
## 6 Genre 6 - country/rock       7        0.17
sample_n(df, 60) %>% count(Genre) %>% mutate(probability = round(n/sum(n), 2))
## # A tibble: 6 × 3
##   Genre                        n probability
##   <chr>                    <int>       <dbl>
## 1 Genre 1 - hiphop/rap        25        0.42
## 2 Genre 2 - pop/kpop/Latin     7        0.12
## 3 Genre 3 -  house/ska         2        0.03
## 4 Genre 4 -  rnb/soul          4        0.07
## 5 Genre 5 - alt/indie/folk    13        0.22
## 6 Genre 6 - country/rock       9        0.15

analyze and synthesize

the data represented from our class matches the generes I hear on shuffle. For my own personal music, it’s definetely a majority of hiphop/rap, and that’s reflected in the class data as well. The most difficult piece of coding was probably organizing that data at first, and after that I began to get the hang of it. I am most proud of my data set that seperates the different genres. If I did this again I would make sure to keep my R-values more lined up, because I often had random gaps between those.