{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) ```{r}
genre_counts <- genre_counts %>% mutate(prob = n/sum(n))
genre_counts
```{r}
genre_counts$prob <- round(genre_counts$prob, 2)
genre_counts
{r} # load necessary libraries library(tidyverse) ```{r}
# import data df <- read_csv(“Playlist - Clean.csv”)
```{r}
#check first few rows of data
head(df)
```{r} # change variable type to factor df\(Genre <- as.factor(df\)Genre) # get the counts for each genre df %>% count(Genre)
```{r}
Genre_counts <- df %>% count(Genre)
#Calculate Theoretical Probabilities
##Next I need to find the theoretical probabilities of getting each genre by creating a new column in my genre counts table.
{r} genre_counts <- genre_counts %>% mutate(prob = n/sum(n)) genre_counts
{r} genre_counts$prob <- round(genre_counts$prob, 2) genre_counts
#Calculating Theoretical Possibilities
```{r} sample <- sample_n(df, 10) sample
```{r}
sample_counts <- sample %>% count(Genre) %>% mutate(probability = n/sum(n))
sample_counts
#Combining Class Values
```{r} combined <- tibble(Genre = Genre_counts$Genre, n = c(2, 3, 0, 1, 2, 2), probability = n/sum(n))
combined
#More Simulations of Shuffle
```{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, 50) %>% count(Genre) %>% mutate(probability = n/sum(n))
{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, 175) %>% count(Genre) %>% mutate(probability =
round(n/sum(n), 2))
```{r}
sample_n(df, 10) %>% count(Genre) %>% mutate(probability = round(n/sum(n), 2))
```{r} sample_n(df, 1) %>% count(Genre) %>% mutate(probability = round(n/sum(n), 2))
``` # Analyze and Synthesize