##INTRODUCTION ##in
playlistdata <- read_csv("playlist - data_clean.csv")
## Rows: 144 Columns: 3
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): genre, artist, title
##
## ℹ 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(playlistdata)
## # A tibble: 6 × 3
## genre artist title
## <chr> <chr> <chr>
## 1 Genre 1 - hiphop/rap Alesso When I'm Gone
## 2 Genre 1 - hiphop/rap Aliyah's Interlude It Girl
## 3 Genre 1 - hiphop/rap Big Sean Beware
## 4 Genre 1 - hiphop/rap Clipse Ma, I don't love her
## 5 Genre 1 - hiphop/rap Common Be
## 6 Genre 1 - hiphop/rap Drake Nice for what
genre <- playlistdata %>% count(genre)
genre
## # A tibble: 6 × 2
## genre n
## <chr> <int>
## 1 Genre 1 - hiphop/rap 26
## 2 Genre 2 - pop/kpop/Latin 22
## 3 Genre 3 - house/ska 5
## 4 Genre 4 - rnb/soul 43
## 5 Genre 5 - alt/indie/folk 34
## 6 Genre 6 - country/rock 14
chance <- genre %>% mutate(prob = n/144)
chance
## # A tibble: 6 × 3
## genre n prob
## <chr> <int> <dbl>
## 1 Genre 1 - hiphop/rap 26 0.181
## 2 Genre 2 - pop/kpop/Latin 22 0.153
## 3 Genre 3 - house/ska 5 0.0347
## 4 Genre 4 - rnb/soul 43 0.299
## 5 Genre 5 - alt/indie/folk 34 0.236
## 6 Genre 6 - country/rock 14 0.0972
sample1<- sample_n(playlistdata,10) %>% count(genre) %>% mutate(prob = n/sum(n))
sample1
## # A tibble: 3 × 3
## genre n prob
## <chr> <int> <dbl>
## 1 Genre 2 - pop/kpop/Latin 2 0.2
## 2 Genre 4 - rnb/soul 6 0.6
## 3 Genre 6 - country/rock 2 0.2
##From the first set of data we see that every genre is included in the first set of songs except a hip hop/rap song. i feel thats because of hip hop having one of the lesser songs in the playlist.
sample2 <- sample_n(playlistdata,5) %>% count(genre) %>% mutate(prob = n/sum(n))
sample2
## # A tibble: 2 × 3
## genre n prob
## <chr> <int> <dbl>
## 1 Genre 1 - hiphop/rap 3 0.6
## 2 Genre 5 - alt/indie/folk 2 0.4
##looking at the second set, i see there are only three genres that were chosen. what makes it more interesting is that the songs chosen were from genres that had the least probability of being chosen.
sample3 <- sample_n(playlistdata,15) %>% count(genre) %>% mutate(prob = n/sum(n))
sample3
## # A tibble: 5 × 3
## genre n prob
## <chr> <int> <dbl>
## 1 Genre 1 - hiphop/rap 3 0.2
## 2 Genre 2 - pop/kpop/Latin 3 0.2
## 3 Genre 3 - house/ska 1 0.0667
## 4 Genre 4 - rnb/soul 7 0.467
## 5 Genre 5 - alt/indie/folk 1 0.0667
##While making these last two samples ive decided to make my last two samples songs a little more to find more probabability.
sample4 <- sample_n(playlistdata,25) %>% count(genre) %>% mutate(prob = n/sum(n))
sample4
## # A tibble: 5 × 3
## genre n prob
## <chr> <int> <dbl>
## 1 Genre 1 - hiphop/rap 6 0.24
## 2 Genre 2 - pop/kpop/Latin 3 0.12
## 3 Genre 4 - rnb/soul 8 0.32
## 4 Genre 5 - alt/indie/folk 6 0.24
## 5 Genre 6 - country/rock 2 0.08
full_join(sample1, sample2, by = "genre")
## # A tibble: 5 × 5
## genre n.x prob.x n.y prob.y
## <chr> <int> <dbl> <int> <dbl>
## 1 Genre 2 - pop/kpop/Latin 2 0.2 NA NA
## 2 Genre 4 - rnb/soul 6 0.6 NA NA
## 3 Genre 6 - country/rock 2 0.2 NA NA
## 4 Genre 1 - hiphop/rap NA NA 3 0.6
## 5 Genre 5 - alt/indie/folk NA NA 2 0.4
sample10 <- sample1 %>% select(genre)