{r} install.packages ("tidyverse")
{r} library("tidyverse")
{r} df <- read_csv("Playlist - Clean.csv")
{r} df <- read_csv("Playlist - Clean.csv")
{r} df$Genre <- as.factor(df$Genre) df %>% count(Genre)
{r} df$Genre<-as.factor(df$Genre)
{r} head(df)
{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
4.4
{r} library(tidyverse)
{r} df <- read_csv("Playlist - Clean.csv")
#check first few rows of data
{r} head(df)
{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 echo=TRUE} 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))