DS4 Song Simulation

Finn Halligan

load tidyverse

{r} install.packages ("tidyverse")

{r} library("tidyverse")

{r} df <- read_csv("Playlist - Clean.csv") {r} df <- read_csv("Playlist - Clean.csv")

{r} df$Genre <- as.factor(df$Genre) df %>% count(Genre)

{r} df$Genre<-as.factor(df$Genre)

{r} head(df)

{r} df %>% count(Genre)

{r} genre_counts <- df %>% count(Genre)

{r} genre_counts <- genre_counts %>% mutate(prob = n/sum(n)) genre_counts

{r} genre_counts$prob <- round(genre_counts$prob, 2) genre_counts ## Genre 1 - hiphop/rap has a 33% chance, Genre 2 - pop/kpop/Latin has a 14% chance Genre 3 - house/ska has 3% chance, Genre 4 - rnb/soul has a 8% chance, Genre 5 - alt/indie/folk has a 26% chance, Genre 6 - country/rock has a 16% of being the the genre.