install.packages("tidyverse")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.3'
## (as 'lib' is unspecified)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.
#Overview
For this project, my classmates and I completed a survery by jotting down 10 songs including the main artist and the specific genre.Next, we created a class playlist with the chosen songs. After, we are going to be playing the playlist in class and figuring out if the genre’s we hear being played on the shuffle represent the genres of the songs in our class playlist.
playlist <- read.csv("/cloud/project/playlist - data_clean.csv")
summary(playlist)
## genre artist title
## Length:144 Length:144 Length:144
## Class :character Class :character Class :character
## Mode :character Mode :character Mode :character
summary(playlist$column1)
## Length Class Mode
## 0 NULL NULL
playlist %>% count(genre)
## genre n
## 1 Genre 1 - hiphop/rap 26
## 2 Genre 2 - pop/kpop/Latin 22
## 3 Genre 3 - house/ska 5
## 4 Genre 4 - rnb/soul 43
## 5 Genre 5 - alt/indie/folk 34
## 6 Genre 6 - country/rock 14
genre_counts<- playlist %>% count (genre)
genre_counts %>%mutate(prob = n/sum(n))
## genre n prob
## 1 Genre 1 - hiphop/rap 26 0.18055556
## 2 Genre 2 - pop/kpop/Latin 22 0.15277778
## 3 Genre 3 - house/ska 5 0.03472222
## 4 Genre 4 - rnb/soul 43 0.29861111
## 5 Genre 5 - alt/indie/folk 34 0.23611111
## 6 Genre 6 - country/rock 14 0.09722222
prob <- read_table("/cloud/project/playlist - data_clean.csv")
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## `genre,artist,title` = col_character()
## )
## Warning: 144 parsing failures.
## row col expected actual file
## 1 -- 1 columns 6 columns '/cloud/project/playlist - data_clean.csv'
## 2 -- 1 columns 6 columns '/cloud/project/playlist - data_clean.csv'
## 3 -- 1 columns 7 columns '/cloud/project/playlist - data_clean.csv'
## 4 -- 1 columns 8 columns '/cloud/project/playlist - data_clean.csv'
## 5 -- 1 columns 4 columns '/cloud/project/playlist - data_clean.csv'
## ... ... ......... ......... ..........................................
## See problems(...) for more details.
library (tidyverse)
star<- genre_counts %>%mutate(prob = n/sum(n))
#interpretation
We began this segment by finding the probability of each genre being played in the playlist we created.
sample_n(playlist, 10)
## genre artist title
## 1 Genre 2 - pop/kpop/Latin olivia.R pretty isnt pretty
## 2 Genre 4 - rnb/soul Queen Naija Medicine
## 3 Genre 1 - hiphop/rap Clipse Ma, I don't love her
## 4 Genre 1 - hiphop/rap little simz two worlds apart
## 5 Genre 6 - country/rock Nirvana Man who sold the world mtv unplugged
## 6 Genre 1 - hiphop/rap Ken carson Murda musik
## 7 Genre 6 - country/rock Citizen Hyper Trophy
## 8 Genre 3 - house/ska Beyonce My house
## 9 Genre 5 - alt/indie/folk Thundercat Them Changes
## 10 Genre 1 - hiphop/rap Jcole Crooked smile
sample_n(playlist, 30)
## genre artist title
## 1 Genre 4 - rnb/soul Ciara Like a boy
## 2 Genre 5 - alt/indie/folk wilco heavy metal drummer
## 3 Genre 4 - rnb/soul Beyonce Summertime
## 4 Genre 2 - pop/kpop/Latin ariana grande honeymoon avenue
## 5 Genre 2 - pop/kpop/Latin bad bunny Ojitos lindos
## 6 Genre 4 - rnb/soul Ghost town djs My boo
## 7 Genre 5 - alt/indie/folk rilo kiley august
## 8 Genre 1 - hiphop/rap Clipse Ma, I don't love her
## 9 Genre 4 - rnb/soul Sade Keep Looking
## 10 Genre 1 - hiphop/rap Jcole change
## 11 Genre 2 - pop/kpop/Latin Lana Del Rey Cinnamon Girl
## 12 Genre 1 - hiphop/rap Mac Miller Surf
## 13 Genre 4 - rnb/soul Fountains of Wayne Halley's Waitress
## 14 Genre 4 - rnb/soul SZA Kill Bill
## 15 Genre 4 - rnb/soul Solange Don't Touch My Hair
## 16 Genre 4 - rnb/soul sza snooze
## 17 Genre 4 - rnb/soul Childish Gambino Redbone
## 18 Genre 5 - alt/indie/folk Cigarettes after sex Sunsetz
## 19 Genre 4 - rnb/soul Marvin Gaye Just to keep you satisfied
## 20 Genre 5 - alt/indie/folk Crumb Plants
## 21 Genre 2 - pop/kpop/Latin Lauv I like me better
## 22 Genre 5 - alt/indie/folk The Shins New Slang
## 23 Genre 1 - hiphop/rap PnB Rock Selfish
## 24 Genre 1 - hiphop/rap Yung Filly Grey
## 25 Genre 5 - alt/indie/folk Aidan Bissett Tripping Over Air
## 26 Genre 4 - rnb/soul Queen Naija Medicine
## 27 Genre 4 - rnb/soul Leon Bridges River
## 28 Genre 4 - rnb/soul Brent Faiyaz Missin Out
## 29 Genre 4 - rnb/soul Kieth Sweat Get up on it
## 30 Genre 6 - country/rock Dolly Parton 9 to 5
sample_n(playlist, 3)
## genre artist title
## 1 Genre 4 - rnb/soul Ella Mai Trip
## 2 Genre 5 - alt/indie/folk AJR Burn The House Down
## 3 Genre 3 - house/ska KAYTRANADA Vex Oh
sample_n(playlist, 15)
## genre artist title
## 1 Genre 4 - rnb/soul Soul for real Candy rain
## 2 Genre 4 - rnb/soul Brent Faiyaz Missin Out
## 3 Genre 2 - pop/kpop/Latin Taeyang Wedding dress
## 4 Genre 5 - alt/indie/folk my bloody valentine To Here Knows When
## 5 Genre 5 - alt/indie/folk the strokes call it fate, call it karma
## 6 Genre 6 - country/rock Luke Combs Hurricane
## 7 Genre 4 - rnb/soul Nico Segal Sunday Candy
## 8 Genre 2 - pop/kpop/Latin Lauv I like me better
## 9 Genre 6 - country/rock luke combs one number away
## 10 Genre 6 - country/rock talking heads this must be the place
## 11 Genre 1 - hiphop/rap Kanye West Everything I Am
## 12 Genre 5 - alt/indie/folk Death Cab for Cutie No Sunlight
## 13 Genre 4 - rnb/soul Ella Mai Shot clock
## 14 Genre 4 - rnb/soul SZA Kill Bill
## 15 Genre 5 - alt/indie/folk Thundercat Them Changes
#interpertation
The song genres were representative in my playlist because there is an equal amount of almost all the genres throughout the playlist of 10. There may be some duplicates but not too many to the point where it is repetitive.My theoretical probabilities and experimental probabilities are different in the sense that my experimental probabilities are more specific to the genres and the likley amount of times that genre would get played.For example,rnb and alt have a higher probability meaning those genres are more likely to get played compared to the rest of the genres. This relates to the analyze and synthesis step of data science because when looking at the rhetorical probabilities. Unlike the theoretical probabilities where we only get an overview of all the songs and their genres. So,we don’t really see the songs/genres categorized and their probability of getting played. That is why, once we do the experimental probability we are able to know more about how much each genre will get played in the playlist and we get to see the genres more categorized by like numbers and their probability.
sky15 <- sample_n(playlist, 15)
sky30 <- sample_n(playlist, 30)
sky15 %>% count (genre)
## genre n
## 1 Genre 1 - hiphop/rap 1
## 2 Genre 2 - pop/kpop/Latin 3
## 3 Genre 4 - rnb/soul 4
## 4 Genre 5 - alt/indie/folk 4
## 5 Genre 6 - country/rock 3
genre_counts<- sky15 %>% count(genre)
genre_counts %>%mutate(prob = n/sum(n))
## genre n prob
## 1 Genre 1 - hiphop/rap 1 0.06666667
## 2 Genre 2 - pop/kpop/Latin 3 0.20000000
## 3 Genre 4 - rnb/soul 4 0.26666667
## 4 Genre 5 - alt/indie/folk 4 0.26666667
## 5 Genre 6 - country/rock 3 0.20000000
prob <- read_table ("/cloud/project/playlist - data_clean.csv")
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## `genre,artist,title` = col_character()
## )
## Warning: 144 parsing failures.
## row col expected actual file
## 1 -- 1 columns 6 columns '/cloud/project/playlist - data_clean.csv'
## 2 -- 1 columns 6 columns '/cloud/project/playlist - data_clean.csv'
## 3 -- 1 columns 7 columns '/cloud/project/playlist - data_clean.csv'
## 4 -- 1 columns 8 columns '/cloud/project/playlist - data_clean.csv'
## 5 -- 1 columns 4 columns '/cloud/project/playlist - data_clean.csv'
## ... ... ......... ......... ..........................................
## See problems(...) for more details.
library(tidyverse)
sky15 <- genre_counts %>%mutate(prob = n/sum(n))
sky15.x <- sky15 %>% select(genre,prob)
sky30 %>% count (genre)
## genre n
## 1 Genre 1 - hiphop/rap 7
## 2 Genre 2 - pop/kpop/Latin 3
## 3 Genre 3 - house/ska 1
## 4 Genre 4 - rnb/soul 11
## 5 Genre 5 - alt/indie/folk 8
genre_counts<- sky30 %>% count(genre)
genre_counts %>%mutate(prob = n/sum(n))
## genre n prob
## 1 Genre 1 - hiphop/rap 7 0.23333333
## 2 Genre 2 - pop/kpop/Latin 3 0.10000000
## 3 Genre 3 - house/ska 1 0.03333333
## 4 Genre 4 - rnb/soul 11 0.36666667
## 5 Genre 5 - alt/indie/folk 8 0.26666667
prob <- read_table ("/cloud/project/playlist - data_clean.csv")
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## `genre,artist,title` = col_character()
## )
## Warning: 144 parsing failures.
## row col expected actual file
## 1 -- 1 columns 6 columns '/cloud/project/playlist - data_clean.csv'
## 2 -- 1 columns 6 columns '/cloud/project/playlist - data_clean.csv'
## 3 -- 1 columns 7 columns '/cloud/project/playlist - data_clean.csv'
## 4 -- 1 columns 8 columns '/cloud/project/playlist - data_clean.csv'
## 5 -- 1 columns 4 columns '/cloud/project/playlist - data_clean.csv'
## ... ... ......... ......... ..........................................
## See problems(...) for more details.
library(tidyverse)
sky30 <- genre_counts %>%mutate(prob = n/sum(n))
sky30.y <- sky30 %>% select(genre,prob)
full_join(sky15,sky30,by = "genre")
## genre n.x prob.x n.y prob.y
## 1 Genre 1 - hiphop/rap 1 0.06666667 7 0.23333333
## 2 Genre 2 - pop/kpop/Latin 3 0.20000000 3 0.10000000
## 3 Genre 4 - rnb/soul 4 0.26666667 11 0.36666667
## 4 Genre 5 - alt/indie/folk 4 0.26666667 8 0.26666667
## 5 Genre 6 - country/rock 3 0.20000000 NA NA
## 6 Genre 3 - house/ska NA NA 1 0.03333333