{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.
{r} sample_n(df,20)%>%count(Genre) %>% mutate(probability = round(n/sum(n), 2))
{r} sample_n(df,30)%>%count(Genre) %>% mutate(probability = round(n/sum(n), 2))
{r} sample_n(df,40)%>%count(Genre) %>% mutate(probability = round(n/sum(n), 2))
{r} sample_n(df,50)%>%count(Genre) %>% mutate(probability = round(n/sum(n), 2))
{r} sample_n(df,60)%>%count(Genre) %>% mutate(probability = round(n/sum(n), 2))
{r} sample_n(df,70)%>%count(Genre) %>% mutate(probability = round(n/sum(n), 2))
# Analyze & Synthesize ### The genres played on shuffle represent
the songs that will be played the most. The evidence I have to support
this is my theoretical, experimental probability and the large sample
playlists. I learned that experimental probability and theoretical
probabilty are calculated differently and I learned how to calculate
them. Almost all of the time the chance for generes hip hop and
alternate will always be more likely to play. The porbability is mostly
greater with theoretical and experimental. # Reflection ### The piece of
code that was the most challenging was definitely the piping operator
and the mutations. I had to ask Ms. Hood for a lot of help. I feel most
proud of the project as a whole but probably the tprob the most. I would
like to learn a lot more about everything, it is hard for me to grasp
the concept as a whole. I feel like coding and CS is a weakness for me
for sure. Not a lot of this makes sense to me at all. I liked learning
more and I required a lot of assistance though. I know math and computer
science is not my strong suit but I think it is really cool.