{r} install.packages("tidyverse")
{r} library(tidyverse)
{r} df <- read_csv("Playlist - Clean.csv")
{r} head(df)
{r} df$genre <- as.factor(df$Genre)
{r} df %>% count(genre)
{r} genre_counts <-df %>% count(genre) head(genre_counts)
{r} genre_counts<-genre_counts %>% mutate(tprob=n/sum(n)) genre_counts
```{r} genre_counts\(tprob <-round(genre_counts\)tprob,2) genre_counts
### Last I rounded my TPROB numbers to two decimal places so they were easier to interperet and read.
### The table shows me that there is a 33% chance of getting a Hip Hop/Rap song, 14% chance of getting a Pop/Kpop/Latin song, 3% of getting a House/Ska song, 8% chance for RnB/Soul song, 26% chance for alt/indie/folk and 16% chance of getting a country/rock song.
# 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
```{r}
playlist<-sample_n(df, 10)
playlist
{r} sample_counts<-playlist%>%count(playlist$Genre) sample_counts
{r} sample_counts%>%mutate(prob=n/sum(n)) ## Yes my
probability matches my playlist pretty well. The probability is .4 for
art/indie/folk and there were four songs of this genre on my playlist.
There was also a .3 experimental prob of hip hop and there were 3 songs
on my playlist. ## When compared to my theoretical probabbility the
biggest experimental was art/indie/folk but theoretical was only .1
running the experimental probability more times could maybe make them
similar.