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.4.4 ✔ 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
playlist<-read.csv ("playlist - data_clean (1).csv")
In this project we took songs from different genres and were seeing thr probability for each song in a shuffle playlist. We were seeing if it would be the same for every genre the comes u for each song. We were also seeing if it depends on the genre you favorite if it gets played more during the shuffle and how would the playlist determine that.
Genres<-playlist%>%count(genre)
Genres
## genre n
## 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
Genres<-Genres%>%mutate(prob = n/sum(n))
Genres
## genre n prob
## 1 Genre 1 - hiphop/rap 26 0.18055556
## 2 Genre 2 - pop/kpop/Latin 22 0.15277778
## 3 Genre 3 - house/ska 5 0.03472222
## 4 Genre 4 - rnb/soul 43 0.29861111
## 5 Genre 5 - alt/indie/folk 34 0.23611111
## 6 Genre 6 - country/rock 14 0.09722222
Shuffle<-sample_n(playlist,10) %>% count(genre) %>% mutate(prob = n/sum(n))
Shuffle
## genre n prob
## 1 Genre 1 - hiphop/rap 1 0.1
## 2 Genre 2 - pop/kpop/Latin 4 0.4
## 3 Genre 4 - rnb/soul 1 0.1
## 4 Genre 5 - alt/indie/folk 2 0.2
## 5 Genre 6 - country/rock 2 0.2
I noticed by looking at these probabiltes the genere with more songs has a higher probability of getting played during the shuffle in the playlist but based on the probabiltes shown its not a very high chance of any song really getting played I think its just kind of randomization in a sense but i think the more songs in the playlist its going to be a lower chance of any song in any genere to be played.
I think the hardest piece of code was remembering the formula for the code to get the right probability of each song. I’m mostly proud of all of it just how i remembered how to write the codes in and actually seeing them work. Nothing is specific just getting more use to the formulas and all the codes to create tables inside the postit.