DS4 Song Simulation

Kaeden Asprocolas

We need to load tidyverse

{r} install.packages("tidyverse")

{r} library(tidyverse)

read playlist / find rows and columns

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

show artist and songs names in the columns

{r} head(df)

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

count Genre

{r} df %>% count(df$Genre)

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

calculate probibilities for Genres

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

show simplified Genre prob

{r} Genre_counts$prob <- round(Genre_counts$prob, 2) Genre_counts