{r echo=TRUE} 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))
{r} genre_counts
{r} genre_counts$prob <- round(genre_counts$prob, 2)
{r} genre_counts
{r} library(tidyverse) # import data
{r} df <- read_csv("playlist - data_clean.csv")
#check first few rows of data {r} head(df)
{r} df$genre <- as.factor(df$genre)
{r} df %>% count(genre)
{r} genre_counts <- df %>% count(genre)
{r} sample <- sample_n(df, 10) sample
{r} sample_counts <- sample %>% count(genre) %>% mutate(probability = n/sum(n)) sample_counts
{r} genre_counts$prob <- round(genre_counts$prob, 2) genre_counts
{r} sample <- sample_n(df, 10) sample ```{r}
sample_counts <- sample %>% count(genre) %>% mutate(probability
= n/sum(n)) sample_counts
```{r}
combined <- tibble(genre = genre_counts$genre, n = c(2, 3, 0, 1, 2, 2), probability = n/sum(n))
combined
```{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, 67) %>% count(genre) %>% mutate(probability = round(n/sum(n), 2))
```{r} sample_n(df, 150) %>% count(genre) %>% mutate(probability = round(n/sum(n), 2))
```{r echo=TRUE}
sample_n(df, 54) %>% count(genre) %>% mutate(probability = round(n/sum(n), 2))