R4DS, Visualizing Billboard Charts

As I’ve mentioned elsewhere on this repository, I am attempting to quantify the meaning of a phrase using sentiment detection. The idea is that when an artist uses a sentence like “we used to kick it but now I can’t stand you”, I hope to understand the valence, negative vs positive of that individual’s usage of the term. This can be done assuming that the valence around that phrasing leaves clues about the most probable polarity of that particular clause.

I am not sure what I am trying to do here. But from what I’ve read so far, if you are not sure what you are looking for in your data set, then try to work some visualizations that will hopefully help you to possibly see some patterns. For instance, see R4DS.

First, I have a dataset consisting of the usual stuff. This time I used chatGPT to help me create a data set of songs and lyrics by scraping these from the website Genius Lyrics. You can see a brief tutorial at the St. Louis Area Digital Humanities Network.

Here, I am importing a csv file that contains 3 columns, artist, title, and lyrics. You can see the resulting object below.

# step 1, import csv file containing 3 columns, Artist, Title, Lyrics. Use 'read_csv2' since this automatically uses ';' for separator.

top_charts <- read_csv("/home/mreynolds/Music_Corpora/songs-2021/lyrics/3-artists-100-lyrics-2021.csv")

# see the first 6 lines of the file

head(top_charts)
## # A tibble: 6 × 3
##   artist            title             lyrics                                    
##   <chr>             <chr>             <chr>                                     
## 1 Machine Gun Kelly RAP DEVIL.        "RAP DEVIL Lyrics.\nOh my God., Ronny.\n\…
## 2 Machine Gun Kelly DAYWALKER!.       "DAYWALKER! Lyrics.\nPunch that motherfuc…
## 3 Machine Gun Kelly ​bloody valentine. "​bloody valentine Lyrics.\nOkay.\nThe sim…
## 4 Pooh Shiesty      Back in Blood.    "Back in Blood Lyrics.\nSmurk (Mmm, mmm, …
## 5 Pooh Shiesty      Switch it Up.     "Switch it Up Lyrics.\n(Gold Haze on the …
## 6 Pooh Shiesty      Shiesty Summer.   "Shiesty Summer Lyrics.\nMmm, mmm, mmm, m…

I then filter by artist and title, in this case “machine gun kelly”. Because mgk had three songs in the top 100 music chart for 2021, I end up with three sets of lyrics, “rap devil”, “day walker”, “bloody valentine”.

### notice that here we are filtering by artist and title
#stapleton <- top_charts %>%
#	filter(Artist == "Chris Stapleton", Title == "Traveller")

#drake <- top_charts %>%
#	filter(Artist == "Drake")
mgk <- top_charts[1:3,3]
kelly_vec <- pull(mgk)
# filter lyrics column into new variable

#kelly_lyrics <- kelly$Lyrics
head(kelly_vec)
## [1] "RAP DEVIL Lyrics.\nOh my God., Ronny.\n\nAyy., somebody grab him some clippers (Zzzzt).\nHis fuckin' beard is weird.\nTough talk from a rapper payin' millions for security a year.\n\"I think my dad's gone crazy,\" yeah, Hailie., you right.\nDad's always mad cooped up in the studio., yellin' at the mic.\nYou're sober and bored., huh? (I know).\n'Bout to be forty-six years old., dog.\nTalkin' 'bout \"I'ma call up Trick Trick\".\nMan, you sound like a bitch., bitch.\nMan up and handle your shit (Ugh).\nMad about somethin' I said in 2012.\nTook you six years and a surprise album just to come with a diss (Huh).\nHomie, we get it., we know that you're the greatest rapper alive.\nFuckin' dweeb., all you do is read the dictionary and stay inside.\nFuck \"Rap God.,\" I'm the Rap Devil.\nComin' bare-faced with a black shovel.\nLike the Armageddon when the smoke settle.\nHis body next to this instrumental., I'm sayin'.\nI'm sick of them sweatsuits and them corny hats., let's talk about it.\nI'm sick of you bein' rich and you still mad., let's talk about it.\nBoth of us single dads from the Midwest., we can talk about it.\nOr we could get gully., I'll size up your body and put some white chalk around it (Ayy).\n\nLet's talk about the fact you actually blackballed a rapper.\nThat's twice as young as you (Let's talk about it).\nLet's call Sway.\nAsk why I can't go up to Shade 45 because of you (Brrt).\nLet's ask Interscope.\nHow you had Paul Rosenberg tryin' to shelf me (Huh?).\nStill can't cover up the fact.\nYour last four albums is as bad as your selfie.\nNow tell me., what do you stand for? (What?).\nI know you can't stand yourself (No).\nTryin' to be the old you so bad., you Stan yourself (Ha).\nLet's leave all the beefin' to 50 (Please).\nEm., you're pushin' fifty.\nWhy you claimin' that I'ma call Puff.\nWhen you the one that called Diddy? (Facts).\nThen you went and called Jimmy (Facts).\nThey conference called me in the morning (What?).\nThey told me you mad about a tweet.\nYou wanted me to say sorry (What?).\nI swear to God I ain't believe him (Nah).\nPlease say it ain't so (No).\nThe big bad bully of the rap game can't take a fuckin' joke.\nOh., you want some fuckin' smoke (What?).\nBut not literally., you'll choke.\nYeah., I'll acknowledge you're the G.O.A.T.\nBut I'm The Gunner, bitch., I got you in the scope (Brrah).\nDon't have a heart attack now (No).\nSomebody help your mans up (Help).\nKnees weak of old age., The Real Slim Shady can't stand up.\nI'm sick of them sweatsuits and them corny hats., let's talk about it (Let's talk).\nI'm sick of you bein' rich and you still mad., let's talk about it (Let's talk).\nBoth of us single dads from the Midwest., we can talk about it (Haha).\nOr we could get gully., I'll size up your body and put some white chalk around it.\n\nHello Marshall., my name's Colson.\nYou should go back to Recovery (Wouh).\nI know your ego is hurtin'.\nJust knowin' that all of your fans discovered me (Hi).\nHe like, \"Damn., he a younger me.\nExcept he dresses better and I'm ugly.\nAlways making fun of me\".\nStop all the thuggery, Marshall., you livin' in luxury (Ayy).\nLook what you done to me.\nDropped an album just because of me.\nDamn., you in love with me.\nYou got money but I'm hungry.\nI like the diss but you won't say them lyrics out in front of me.\nShout out to every rapper that's up under me.\nKnow that I'll never do you like this fuckery.\nStill bitter after everyone loves you.\nPull that wedgie out your dungarees (Ayy).\nI gotta respect the OGs and I know most of 'em personally (Ayy).\nBut you're just a bully actin' like a baby.\nSo I gotta read you a nursery (Pussy).\nI'm the ghost of the future.\nAnd you're just Ebenezer Scrooge (Facts).\nI said on Flex anyone could get it.\nI ain't know it would be you.\nI'm sick of them sweatsuits and them corny hats., let's talk about it (Let's talk).\nI'm sick of you bein' rich and you still mad., let's talk about it (Let's talk).\nBoth of us single dads from the Midwest., we can talk about it (Haha).\nOr we could get gully., I'll size up your body and put some white chalk around it.\nAyy., ridin' shotty 'cause I gotta roll this dope.\nIt's a fast road when your idols become your rivals., yeah.\nNever hesitate to say it to your face., I'm an asshole.\nBitch-ass motherfucker.\nOh my God., Ronny.\nFuck Kells.\n\nWe know you get nervous., Rabbit.\nI see Mama's spaghetti all over your sweater.\nI wish you would lose yourself on the records.\nThat you made a decade ago., they were better.\nAccordin' to them., you're a national treasure.\nTo me., you're as soft as a feather.\nThe type to be scared to ask Rihanna for her number.\nJust hold her umbrella-ella-ella.\n\"I'm not afraid,\" okay Oscar the Grouch., chill on the couch (Fuck).\nYou got an Oscar., damn.\nCan anyone else get some food in their mouth? (For real).\nThey made a movie about you., you're in everybody's top ten.\nYou're not getting better with time.\nIt's fine, Eminem., put down the pen.\nOr write an apology.\nOver the simple fact., you had to diss to acknowledge me.\nI am the prodigy.\nHow could I even look up to you? You ain't as tall as me.\n5'8\" and I'm 6'4\"., seven punches hold your head still.\nLast time you saw 8 Mile was at home on a treadmill.\nYou were named after a candy.\nI was named after a gangster (Brr).\nAnd don't be a sucker and take my verse off of Yelawolf's album., thank you (Thank you).\nI just wanna feed my daughter.\nYou tryna stop the money to support her.\nYou the one always talkin' 'bout the action.\nText me the addy., I'm pullin' up scrappin'.\nAnd I'm by my fuckin' self., what's happenin'.\nEST captain., salute me or shoot me.\nThat's what he's gonna have to do to me.\nWhen he realizes there ain't shit he could do to me.\nEverybody always hated me., this isn't anything new to me.\nYeah there's a difference between us.\nI got all of my shit without Dre producin' me (Ayy).\nI know you're not used to me.\nUsually one of your disses should ruin me.\nBut bitch I'm from Cleveland.\nEverybody quiet this evenin'., I'm readin' the eulogy (Shh).\nDropped an album called Kamikaze.\nSo that means he killed him.\nAlready fucked one rapper's girl this week.\nDon't make me call Kim.\n\nI'm sick of them sweatsuits and them corny hats., let's talk about it (Let's talk).\nI'm sick of you bein' rich and you still mad., let's talk about it (Let's talk).\nBoth of us single dads from the Midwest., we can talk about it (Haha).\nOr we could get gully., I'll size up your body and put some white chalk around it342Embed."
## [2] "DAYWALKER! Lyrics.\nPunch that motherfucker in the face.\nYou hated what he said., right?.\nBeat his ass., leave him at the stoplight.\nI know you wanted change., but nobody's around.\nSo, kick him again while he's on the ground., yo.\nI'll never be the same.\nI wanna know if I tell you a secret., will you keep it?.\nI need someone to blame (Take it!).\nAnd I see somebody talkin' with a mouth that's full of teeth I wanna break (Go).\n\nFight, fight, fight., fight.\nFight, fight, fight., fight.\nFight, fight, fight., fight.\nFight, fight, yeah., yeah.\nThey tried to kill me in the rain.\nTried to lay me down and so I dodged and ran away.\nPut a gun up to my face., so I'll fucking catch a case (A case).\nWhen I find this mothеrfucker., gonna lay him in his grave.\nAll thesе fucking razorblades.\nI wanna know if I tell you a secret., will you keep it?.\nI won't ever be the same.\nI bit the fucking apple., I'm surrounded by some snakes (CORPSE).\n\nFight, fight, fight., fight.\nFight, fight, fight., fight.\nFight, fight, fight., fight.\nFight, fight (Yeah, yeah)., fight.\n\nSdnah ydoolb.\nBloody.\nSdnah ydoolb.\n\nI prayed to God and then I went to sleep with bloody hands.\nInside my room., I heard the sirens from the ambulance.\nI chipped my tooth and then I found a piece inside my pants.\nHe talkin' shit, when he wake up., I go do that again.\nI came back.\nI wanna know if I tell you a secret., will you keep it?.\nIf a pussy wanna say shit., then I'll fuckin' stomp his face in.\nNah, not getting better, can't change it., I left blood all on the pavement.\nI'm on borrowed time, can't shake it, uh, blackout when I'm ragin'., uh.\nMe and all these pills be on a fuckin' first name basis., uh.\nThere's an invisible voice that is talkin' to me and it's always tellin' me to kill.\nI got a problem with separating what my head is creating from things that are real.\nI'm in a room., hyperventilating and debating to pop off the cap of these pills.\nIf I get angry., I'm goin' to start up a riot like people on Capitol Hill.\nFight, fight, fight., fight.\nFight, fight, fight., fight.\nFight, fight, fight., fight.\nFight, fight (Yeah, yeah)., fight.\n\nThe end180Embed."                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
## [3] "​bloody valentine Lyrics.\nOkay.\nThe simulation just went bad.\nBut you're the best I ever had.\nLike handprints in wet cement.\nShe touched me., it's permanent.\n\nIn my head., in my head.\nI couldn't hear anything you said., but.\nIn my head., in my head.\nI'm callin' you \"girlfriend.,\" what the fuck?.\n\nI don't do fake love.\nBut I'll take some from you tonight.\nI know I've got to go.\nBut I might just miss the flight.\nI can't stay forever., let's play pretend.\nAnd treat this night like it'll happen again.\nYou'll be my bloody valentine tonight.\nI'm overstimulated and I'm sad.\nI don't expect you to understand.\nIt's nothing less than true romance.\nOr am I just makin' a mess?.\n\nIn my head., in my head.\nI'm lyin' naked with you., yeah.\nIn my head., in my head.\nI'm ready to die holding your hand.\n\nI don't do fake love.\nBut I'll take some from you tonight (Take some from you tonight).\nI know I've got to go.\nBut I might just miss the flight.\nI can't stay forever., let's play pretend.\nAnd treat this night like it'll happen again.\nYou'll be my bloody valentine tonight.\n\nI can't hide.\nHow I feel about you inside.\nI'd give everything up tonight.\nIf I could just have you., be mine.\nBe mine., baby.\nI can't hide (I cannot hide these feelings., no).\nHow I feel about you inside (I cannot hide these feelings).\nI'd give everything up tonight (I'd give up everything for you).\nIf I could just have you., be mine (I'd give up everything).\nBe mine (Ayy).\nI don't do fake love.\nBut I'll take some from you tonight (Take some from you tonight).\nI know I've got to go.\nBut I might just miss the flight.\nI can't stay forever., let's play pretend.\nAnd treat this night like it'll happen again.\nYou'll be my bloody valentine tonight.\n\nNo-no-no., no-no-no.\nNo-no-no., not just tonight.\nNo-no-no., no-no-no.\nNo-no-no., not just tonight.\nNo-no-no., no-no-no.\nNo-no-no., not just tonight.\nNo-no-no, no-no-no (In my head., in my head).\nNo-no-no., not just tonight.\n(Were we on time? Should we try—)46Embed."
mgk2 <- top_charts[1:250,3]

head(presidential_debates_2012)
## # A tibble: 6 × 5
##   person tot   time   role      dialogue                                        
##   <fct>  <chr> <fct>  <fct>     <chr>                                           
## 1 LEHRER 1.1   time 1 moderator We'll talk about specifically about health care…
## 2 LEHRER 1.2   time 1 moderator But what do you support the voucher system, Gov…
## 3 ROMNEY 2.1   time 1 candidate What I support is no change for current retiree…
## 4 ROMNEY 2.2   time 1 candidate And the president supports taking dollar seven …
## 5 LEHRER 3.1   time 1 moderator And what about the vouchers?                    
## 6 ROMNEY 4.1   time 1 candidate So that's that's number one.
head(top_charts)
## # A tibble: 6 × 3
##   artist            title             lyrics                                    
##   <chr>             <chr>             <chr>                                     
## 1 Machine Gun Kelly RAP DEVIL.        "RAP DEVIL Lyrics.\nOh my God., Ronny.\n\…
## 2 Machine Gun Kelly DAYWALKER!.       "DAYWALKER! Lyrics.\nPunch that motherfuc…
## 3 Machine Gun Kelly ​bloody valentine. "​bloody valentine Lyrics.\nOkay.\nThe sim…
## 4 Pooh Shiesty      Back in Blood.    "Back in Blood Lyrics.\nSmurk (Mmm, mmm, …
## 5 Pooh Shiesty      Switch it Up.     "Switch it Up Lyrics.\n(Gold Haze on the …
## 6 Pooh Shiesty      Shiesty Summer.   "Shiesty Summer Lyrics.\nMmm, mmm, mmm, m…
presidential_debates_2012 %>%
    dplyr::mutate(dialogue_split = get_sentences(dialogue)) %$%
    sentiment_by(dialogue_split, list(person, time))
##        person   time word_count        sd ave_sentiment
##  1:     OBAMA time 1       3599 0.2535006    0.12256892
##  2:     OBAMA time 2       7477 0.2509177    0.11217673
##  3:     OBAMA time 3       7243 0.2441394    0.07975688
##  4:    ROMNEY time 1       4085 0.2525596    0.10151917
##  5:    ROMNEY time 2       7536 0.2205169    0.08791018
##  6:    ROMNEY time 3       8303 0.2623534    0.09968544
##  7:   CROWLEY time 2       1672 0.2181662    0.19455290
##  8:    LEHRER time 1        765 0.2973360    0.15473364
##  9:  QUESTION time 2        583 0.1756778    0.03197751
## 10: SCHIEFFER time 3       1445 0.2345187    0.08843478
out <- with(
    presidential_debates_2012, 
    sentiment_by(
        get_sentences(dialogue), 
        list(person, time)))

plot(out)

top_charts$artist <- as.factor(top_charts$artist)
top_charts$title <- as.factor(top_charts$title)

head(top_charts)
## # A tibble: 6 × 3
##   artist            title             lyrics                                    
##   <fct>             <fct>             <chr>                                     
## 1 Machine Gun Kelly RAP DEVIL.        "RAP DEVIL Lyrics.\nOh my God., Ronny.\n\…
## 2 Machine Gun Kelly DAYWALKER!.       "DAYWALKER! Lyrics.\nPunch that motherfuc…
## 3 Machine Gun Kelly ​bloody valentine. "​bloody valentine Lyrics.\nOkay.\nThe sim…
## 4 Pooh Shiesty      Back in Blood.    "Back in Blood Lyrics.\nSmurk (Mmm, mmm, …
## 5 Pooh Shiesty      Switch it Up.     "Switch it Up Lyrics.\n(Gold Haze on the …
## 6 Pooh Shiesty      Shiesty Summer.   "Shiesty Summer Lyrics.\nMmm, mmm, mmm, m…
out2 <- with(
    top_charts, 
    sentiment_by(
        get_sentences(lyrics), 
        list(title, artist)))

plot(out2)

Next, I begin to run some sentiment analysis on these lyrics using Sentimentr. Sentimentr is an approach to sentiment detection that takes valence modifiers, very, not very, etc into account when accessing the polarity of the sentiment of a word or sentence, whether negative or positive and by how much. The choice is between -1 and 1.

I will begin with the overall sentiment at the sentence level.

# using sentimentr's get_sentences function, get sentences
kelly_sentences <- get_sentences(kelly_vec)

# get sentiment, using 'sentiment_by' which aggregates by element (column or vector element)

kelly_sentiment <- sentiment(kelly_sentences)
plot(kelly_sentiment)

Each element id is a sentence. I am not sure how accurate these are. After importing the lyrics from genius lyrics into a csv file, I replaced each line ending \n with a period. I left other punctuation alone, although I will likely go back and replace the original punctuation like question marks, etc.

Next are aggregated sentences by groups.

kelly_sentimentby <- sentiment_by(kelly_sentences)
plot(kelly_sentimentby)

The previous sets do not say much, therefore I will next filter out negative valences.

kelly_positive <- filter(kelly_sentiment, sentiment > 0)
kelly_positive
##     element_id sentence_id word_count  sentiment
##  1:          5           1         11 0.19598237
##  2:          6           1         10 0.01581139
##  3:         16           1         12 0.28867513
##  4:         20           1          7 0.09449112
##  5:         21           1          8 0.17677670
##  6:         24           1         13 0.11094004
##  7:         25           1         18 0.09428090
##  8:         26           1         10 0.12649111
##  9:         27           1         10 0.25298221
## 10:         38           1          7 0.28347335
## 11:         42           1          1 0.40000000
## 12:         43           1          7 0.15118579
## 13:         48           1          6 0.40824829
## 14:         57           1         15 0.01290994
## 15:         59           1         14 0.10690450
## 16:         60           1         17 0.09701425
## 17:         62           1          7 0.09449112
## 18:         64           1         10 0.18973666
## 19:         66           1          7 0.01889822
## 20:         67           1          5 0.33541020
## 21:         68           1         10 0.03162278
## 22:         73           1         15 0.12884125
## 23:         76           1          6 0.20412415
## 24:         78           1         13 0.13867505
## 25:         80           1          8 0.07071068
## 26:         82           1          6 0.16329932
## 27:         84           1          7 0.39686270
## 28:         85           1         15 0.01290994
## 29:         87           1         14 0.10690450
## 30:         88           1         17 0.09701425
## 31:         90           1         11 0.30151134
## 32:         98           1          9 0.26666667
## 33:         99           1          7 0.28347335
## 34:        100           1          8 0.21213203
## 35:        105           1          9 0.13333333
## 36:        107           1         11 0.30151134
## 37:        109           1          7 0.09449112
## 38:        110           1          4 0.30000000
## 39:        112           1          4 0.25000000
## 40:        119           1         17 0.36380344
## 41:        120           1          6 0.24494897
## 42:        121           1          8 0.24748737
## 43:        122           1          8 0.08838835
## 44:        127           1         11 0.22613351
## 45:        134           1          9 0.08333333
## 46:        139           1         15 0.01290994
## 47:        141           1         14 0.10690450
## 48:        142           1         18 0.09428090
## 49:        146           1          6 0.12247449
## 50:        175           1         13 0.16641006
## 51:        181           1         13 0.20801257
## 52:        195           1          7 0.42521003
## 53:        196           1          5 0.22360680
## 54:        207           1          8 0.17677670
## 55:        211           1          6 0.36742346
## 56:        216           1          7 0.01889822
## 57:        222           1          8 0.17677670
## 58:        228           1          3 0.34641016
## 59:        239           1          8 0.17677670
## 60:        249           1          4 0.50000000
##     element_id sentence_id word_count  sentiment

Then filter out positive valences.

kelly_negative <- filter(kelly_sentiment, sentiment < 0)
kelly_negative
##     element_id sentence_id word_count   sentiment
##  1:          1           1          3 -0.28867513
##  2:          4           1          5 -0.11180340
##  3:          7           1         12 -0.21650635
##  4:          8           1          5 -0.67082039
##  5:         11           1          7 -0.37796447
##  6:         12           1          7 -0.56694671
##  7:         13           1          7 -0.37796447
##  8:         14           1          6 -0.30618622
##  9:         15           1         15 -0.10327956
## 10:         18           1          7 -0.56694671
## 11:         19           1          7 -0.09449112
## 12:         22           1         13 -0.09707253
## 13:         23           1         14 -0.16035675
## 14:         33           1         10 -0.23717082
## 15:         37           1         12 -0.21650635
## 16:         45           1          8 -0.26516504
## 17:         46           1          7 -0.18898224
## 18:         47           1          9 -0.03333333
## 19:         49           1         13 -0.51309768
## 20:         50           1          7 -0.09449112
## 21:         51           1          5 -0.33541020
## 22:         53           1         12 -0.28867513
## 23:         54           1          7 -0.28347335
## 24:         56           1         12 -0.15011107
## 25:         58           1         16 -0.05000000
## 26:         63           1          6 -0.10206207
## 27:         72           1          6 -0.22939471
## 28:         75           1          9 -0.16666667
## 29:         79           1          9 -0.19583333
## 30:         81           1          6 -0.24494897
## 31:         86           1         16 -0.05000000
## 32:         89           1          9 -0.08333333
## 33:         91           1         11 -0.07537784
## 34:         92           1          3 -1.44337567
## 35:         94           1          2 -0.70710678
## 36:         95           1          6 -0.30618622
## 37:         97           1          9 -0.75000000
## 38:        101           1         11 -0.15075567
## 39:        103           1         12 -0.38971143
## 40:        104           1          5 -0.33541020
## 41:        108           1          6 -0.32659863
## 42:        111           1         11 -0.30151134
## 43:        118           1          7 -0.37796447
## 44:        125           1          7 -0.09449112
## 45:        128           1         10 -0.41109610
## 46:        130           1         11 -0.22613351
## 47:        132           1          8 -0.61871843
## 48:        133           1          5 -1.00623059
## 49:        135           1          5 -0.44721360
## 50:        136           1          6 -0.20412415
## 51:        137           1          7 -0.30237158
## 52:        140           1         16 -0.05000000
## 53:        145           1          6 -0.61237244
## 54:        147           1          8 -0.26516504
## 55:        149           1         10 -0.07905694
## 56:        152           1          7 -0.28347335
## 57:        153           1         16 -0.06250000
## 58:        154           1          4 -1.00000000
## 59:        155           1          4 -1.00000000
## 60:        156           1          4 -1.00000000
## 61:        157           1          4 -0.50000000
## 62:        158           1          8 -0.26516504
## 63:        160           1         15 -0.16782928
## 64:        161           1         11 -0.15075567
## 65:        162           1          4 -0.07500000
## 66:        165           1         11 -0.27136021
## 67:        166           1          4 -1.00000000
## 68:        167           1          4 -1.00000000
## 69:        168           1          4 -1.00000000
## 70:        169           1          5 -0.67082039
## 71:        171           1          1 -0.75000000
## 72:        173           1         13 -0.20801257
## 73:        176           1         12 -0.21650635
## 74:        179           1         13 -0.31895261
## 75:        180           1         14 -0.21380899
## 76:        183           1         16 -0.43750000
## 77:        184           1         16 -0.18750000
## 78:        186           1         16 -0.18750000
## 79:        187           1          4 -1.00000000
## 80:        188           1          4 -1.00000000
## 81:        189           1          4 -1.00000000
## 82:        190           1          5 -0.67082039
## 83:        192           1          3 -0.43301270
## 84:        194           1          5 -0.33541020
## 85:        201           1          7 -0.37796447
## 86:        205           1          7 -0.85042006
## 87:        206           1          7 -0.28347335
## 88:        208           1          6 -0.30618622
## 89:        209           1          5 -0.22360680
## 90:        210           1          6 -0.57154761
## 91:        212           1          7 -0.28347335
## 92:        220           1          7 -0.85042006
## 93:        221           1          7 -0.28347335
## 94:        223           1          6 -0.30618622
## 95:        237           1          7 -0.85042006
## 96:        238           1          7 -0.28347335
## 97:        240           1          6 -0.30618622
##     element_id sentence_id word_count   sentiment

And so that we get a nice pretty picture of specifically which groups are positive and which are negative, I will use sentimentr’s highlight function to create an html page with each sentence highlighted appropriately.

# creates separate html that highlights sentences according to valence +-.

highlight(kelly_sentimentby)

# creates separate html that highlights sentences according to valence +-.
kellyhl <- highlight(kelly_sentimentby)
kellyhl
## [1] 0
# same thing for drake
# Drake


#drake

Before that however, it will help to have some control sentences.

mytext <- c(
    'do you like it?  But I hate really bad dogs',
    'I am the best friend.',
    'Do you really like it?  I\'m not a fan'
)
mytext <- get_sentences(mytext)
mytext1 <- sentiment_by(mytext)
mytext
## [1] "do you like it?"            "But I hate really bad dogs"
## [3] "I am the best friend."      "Do you really like it?"    
## [5] "I'm not a fan"
mytext1
##    element_id word_count sd ave_sentiment
## 1:          1          4 NA     0.2500000
## 2:          2          6 NA    -1.8677359
## 3:          3          5 NA     0.5813777
## 4:          4          5 NA     0.4024922
## 5:          5          4 NA     0.0000000
highlight(mytext1)
Polarity

1: -.289

RAP DEVIL Lyrics.

2: .000

Oh my God., Ronny.

3: .000

Ayy., somebody grab him some clippers (Zzzzt).

4: -.112

His fuckin' beard is weird.

5: +.196

Tough talk from a rapper payin' millions for security a year.

6: +.016

"I think my dad's gone crazy," yeah, Hailie., you right.

7: -.217

Dad's always mad cooped up in the studio., yellin' at the mic.

8: -.671

You're sober and bored., huh?

9: .000

(I know).

10: .000

'Bout to be forty-six years old., dog.

11: -.378

Talkin' 'bout "I'ma call up Trick Trick".

12: -.567

Man, you sound like a bitch., bitch.

13: -.378

Man up and handle your shit (Ugh).

14: -.306

Mad about somethin' I said in 2012.

15: -.103

Took you six years and a surprise album just to come with a diss (Huh).

16: +.289

Homie, we get it., we know that you're the greatest rapper alive.

17: .000

Fuckin' dweeb., all you do is read the dictionary and stay inside.

18: -.567

Fuck "Rap God.," I'm the Rap Devil.

19: -.094

Comin' bare-faced with a black shovel.

20: +.094

Like the Armageddon when the smoke settle.

21: +.177

His body next to this instrumental., I'm sayin'.

22: -.097

I'm sick of them sweatsuits and them corny hats., let's talk about it.

23: -.160

I'm sick of you bein' rich and you still mad., let's talk about it.

24: +.111

Both of us single dads from the Midwest., we can talk about it.

25: +.094

Or we could get gully., I'll size up your body and put some white chalk around it (Ayy).

26: +.126

Let's talk about the fact you actually blackballed a rapper.

27: +.253

That's twice as young as you (Let's talk about it).

28: .000

Let's call Sway.

29: .000

Ask why I can't go up to Shade 45 because of you (Brrt).

30: .000

Let's ask Interscope.

31: .000

How you had Paul Rosenberg tryin' to shelf me (Huh?).

32: .000

Still can't cover up the fact.

33: -.237

Your last four albums is as bad as your selfie.

34: .000

Now tell me., what do you stand for?

35: .000

(What?).

36: .000

I know you can't stand yourself (No).

37: -.217

Tryin' to be the old you so bad., you Stan yourself (Ha).

38: +.283

Let's leave all the beefin' to 50 (Please).

39: .000

Em., you're pushin' fifty.

40: .000

Why you claimin' that I'ma call Puff.

41: .000

When you the one that called Diddy?

42: +.400

(Facts).

43: +.151

Then you went and called Jimmy (Facts).

44: .000

They conference called me in the morning (What?).

45: -.265

They told me you mad about a tweet.

46: -.189

You wanted me to say sorry (What?).

47: -.033

I swear to God I ain't believe him (Nah).

48: +.408

Please say it ain't so (No).

49: -.513

The big bad bully of the rap game can't take a fuckin' joke.

50: -.094

Oh., you want some fuckin' smoke (What?).

51: -.335

But not literally., you'll choke.

52: .000

Yeah., I'll acknowledge you're the G.O.A.T.

53: -.289

But I'm The Gunner, bitch., I got you in the scope (Brrah).

54: -.283

Don't have a heart attack now (No).

55: .000

Somebody help your mans up (Help).

56: -.150

Knees weak of old age., The Real Slim Shady can't stand up.

57: +.013

I'm sick of them sweatsuits and them corny hats., let's talk about it (Let's talk).

58: -.050

I'm sick of you bein' rich and you still mad., let's talk about it (Let's talk).

59: +.107

Both of us single dads from the Midwest., we can talk about it (Haha).

60: +.097

Or we could get gully., I'll size up your body and put some white chalk around it.

61: .000

Hello Marshall., my name's Colson.

62: +.094

You should go back to Recovery (Wouh).

63: -.102

I know your ego is hurtin'.

64: +.190

Just knowin' that all of your fans discovered me (Hi).

65: .000

He like, "Damn., he a younger me.

66: +.019

Except he dresses better and I'm ugly.

67: +.335

Always making fun of me".

68: +.032

Stop all the thuggery, Marshall., you livin' in luxury (Ayy).

69: .000

Look what you done to me.

70: .000

Dropped an album just because of me.

71: .000

Damn., you in love with me.

72: -.229

You got money but I'm hungry.

73: +.129

I like the diss but you won't say them lyrics out in front of me.

74: .000

Shout out to every rapper that's up under me.

75: -.167

Know that I'll never do you like this fuckery.

76: +.204

Still bitter after everyone loves you.

77: .000

Pull that wedgie out your dungarees (Ayy).

78: +.139

I gotta respect the OGs and I know most of 'em personally (Ayy).

79: -.196

But you're just a bully actin' like a baby.

80: +.071

So I gotta read you a nursery (Pussy).

81: -.245

I'm the ghost of the future.

82: +.163

And you're just Ebenezer Scrooge (Facts).

83: .000

I said on Flex anyone could get it.

84: +.397

I ain't know it would be you.

85: +.013

I'm sick of them sweatsuits and them corny hats., let's talk about it (Let's talk).

86: -.050

I'm sick of you bein' rich and you still mad., let's talk about it (Let's talk).

87: +.107

Both of us single dads from the Midwest., we can talk about it (Haha).

88: +.097

Or we could get gully., I'll size up your body and put some white chalk around it.

89: -.083

Ayy., ridin' shotty 'cause I gotta roll this dope.

90: +.302

It's a fast road when your idols become your rivals., yeah.

91: -.075

Never hesitate to say it to your face., I'm an asshole.

92: -1.443

Bitch-ass motherfucker.

93: .000

Oh my God., Ronny.

94: -.707

Fuck Kells.

95: -.306

We know you get nervous., Rabbit.

96: .000

I see Mama's spaghetti all over your sweater.

97: -.750

I wish you would lose yourself on the records.

98: +.267

That you made a decade ago., they were better.

99: +.283

Accordin' to them., you're a national treasure.

100: +.212

To me., you're as soft as a feather.

101: -.151

The type to be scared to ask Rihanna for her number.

102: .000

Just hold her umbrella-ella-ella.

103: -.390

"I'm not afraid," okay Oscar the Grouch., chill on the couch (Fuck).

104: -.335

You got an Oscar., damn.

105: +.133

Can anyone else get some food in their mouth?

106: .000

(For real).

107: +.302

They made a movie about you., you're in everybody's top ten.

108: -.327

You're not getting better with time.

109: +.094

It's fine, Eminem., put down the pen.

110: +.300

Or write an apology.

111: -.302

Over the simple fact., you had to diss to acknowledge me.

112: +.250

I am the prodigy.

113: .000

How could I even look up to you?

114: .000

You ain't as tall as me.

115: .000

5'8" and I'm 6'4"., seven punches hold your head still.

116: .000

Last time you saw 8 Mile was at home on a treadmill.

117: .000

You were named after a candy.

118: -.378

I was named after a gangster (Brr).

119: +.364

And don't be a sucker and take my verse off of Yelawolf's album., thank you (Thank you).

120: +.245

I just wanna feed my daughter.

121: +.247

You tryna stop the money to support her.

122: +.088

You the one always talkin' 'bout the action.

123: .000

Text me the addy., I'm pullin' up scrappin'.

124: .000

And I'm by my fuckin' self., what's happenin'.

125: -.094

EST captain., salute me or shoot me.

126: .000

That's what he's gonna have to do to me.

127: +.226

When he realizes there ain't shit he could do to me.

128: -.411

Everybody always hated me., this isn't anything new to me.

129: .000

Yeah there's a difference between us.

130: -.226

I got all of my shit without Dre producin' me (Ayy).

131: .000

I know you're not used to me.

132: -.619

Usually one of your disses should ruin me.

133: -1.006

But bitch I'm from Cleveland.

134: +.083

Everybody quiet this evenin'., I'm readin' the eulogy (Shh).

135: -.447

Dropped an album called Kamikaze.

136: -.204

So that means he killed him.

137: -.302

Already fucked one rapper's girl this week.

138: .000

Don't make me call Kim.

139: +.013

I'm sick of them sweatsuits and them corny hats., let's talk about it (Let's talk).

140: -.050

I'm sick of you bein' rich and you still mad., let's talk about it (Let's talk).

141: +.107

Both of us single dads from the Midwest., we can talk about it (Haha).

142: +.094

Or we could get gully., I'll size up your body and put some white chalk around it342Embed.

143: .000

DAYWALKER!

144: .000

Lyrics.

145: -.612

Punch that motherfucker in the face.

146: +.122

You hated what he said., right?.

147: -.265

Beat his ass., leave him at the stoplight.

148: .000

I know you wanted change., but nobody's around.

149: -.079

So, kick him again while he's on the ground., yo.

150: .000

I'll never be the same.

151: .000

I wanna know if I tell you a secret., will you keep it?.

152: -.283

I need someone to blame (Take it!).

153: -.062

And I see somebody talkin' with a mouth that's full of teeth I wanna break (Go).

154: -1.000

Fight, fight, fight., fight.

155: -1.000

Fight, fight, fight., fight.

156: -1.000

Fight, fight, fight., fight.

157: -.500

Fight, fight, yeah., yeah.

158: -.265

They tried to kill me in the rain.

159: .000

Tried to lay me down and so I dodged and ran away.

160: -.168

Put a gun up to my face., so I'll fucking catch a case (A case).

161: -.151

When I find this mothеrfucker., gonna lay him in his grave.

162: -.075

All thesе fucking razorblades.

163: .000

I wanna know if I tell you a secret., will you keep it?.

164: .000

I won't ever be the same.

165: -.271

I bit the fucking apple., I'm surrounded by some snakes (CORPSE).

166: -1.000

Fight, fight, fight., fight.

167: -1.000

Fight, fight, fight., fight.

168: -1.000

Fight, fight, fight., fight.

169: -.671

Fight, fight (Yeah, yeah)., fight.

170: .000

Sdnah ydoolb.

171: -.750

Bloody.

172: .000

Sdnah ydoolb.

173: -.208

I prayed to God and then I went to sleep with bloody hands.

174: .000

Inside my room., I heard the sirens from the ambulance.

175: +.166

I chipped my tooth and then I found a piece inside my pants.

176: -.217

He talkin' shit, when he wake up., I go do that again.

177: .000

I came back.

178: .000

I wanna know if I tell you a secret., will you keep it?.

179: -.319

If a pussy wanna say shit., then I'll fuckin' stomp his face in.

180: -.214

Nah, not getting better, can't change it., I left blood all on the pavement.

181: +.208

I'm on borrowed time, can't shake it, uh, blackout when I'm ragin'., uh.

182: .000

Me and all these pills be on a fuckin' first name basis., uh.

183: -.438

There's an invisible voice that is talkin' to me and it's always tellin' me to kill.

184: -.188

I got a problem with separating what my head is creating from things that are real.

185: .000

I'm in a room., hyperventilating and debating to pop off the cap of these pills.

186: -.188

If I get angry., I'm goin' to start up a riot like people on Capitol Hill.

187: -1.000

Fight, fight, fight., fight.

188: -1.000

Fight, fight, fight., fight.

189: -1.000

Fight, fight, fight., fight.

190: -.671

Fight, fight (Yeah, yeah)., fight.

191: .000

The end180Embed.

192: -.433

​bloody valentine Lyrics.

193: .000

Okay.

194: -.335

The simulation just went bad.

195: +.425

But you're the best I ever had.

196: +.224

Like handprints in wet cement.

197: .000

She touched me., it's permanent.

198: .000

In my head., in my head.

199: .000

I couldn't hear anything you said., but.

200: .000

In my head., in my head.

201: -.378

I'm callin' you "girlfriend.," what the fuck?.

202: .000

I don't do fake love.

203: .000

But I'll take some from you tonight.

204: .000

I know I've got to go.

205: -.850

But I might just miss the flight.

206: -.283

I can't stay forever., let's play pretend.

207: +.177

And treat this night like it'll happen again.

208: -.306

You'll be my bloody valentine tonight.

209: -.224

I'm overstimulated and I'm sad.

210: -.572

I don't expect you to understand.

211: +.367

It's nothing less than true romance.

212: -.283

Or am I just makin' a mess?.

213: .000

In my head., in my head.

214: .000

I'm lyin' naked with you., yeah.

215: .000

In my head., in my head.

216: +.019

I'm ready to die holding your hand.

217: .000

I don't do fake love.

218: .000

But I'll take some from you tonight (Take some from you tonight).

219: .000

I know I've got to go.

220: -.850

But I might just miss the flight.

221: -.283

I can't stay forever., let's play pretend.

222: +.177

And treat this night like it'll happen again.

223: -.306

You'll be my bloody valentine tonight.

224: .000

I can't hide.

225: .000

How I feel about you inside.

226: .000

I'd give everything up tonight.

227: .000

If I could just have you., be mine.

228: +.346

Be mine., baby.

229: .000

I can't hide (I cannot hide these feelings., no).

230: .000

How I feel about you inside (I cannot hide these feelings).

231: .000

I'd give everything up tonight (I'd give up everything for you).

232: .000

If I could just have you., be mine (I'd give up everything).

233: .000

Be mine (Ayy).

234: .000

I don't do fake love.

235: .000

But I'll take some from you tonight (Take some from you tonight).

236: .000

I know I've got to go.

237: -.850

But I might just miss the flight.

238: -.283

I can't stay forever., let's play pretend.

239: +.177

And treat this night like it'll happen again.

240: -.306

You'll be my bloody valentine tonight.

241: .000

No-no-no., no-no-no.

242: .000

No-no-no., not just tonight.

243: .000

No-no-no., no-no-no.

244: .000

No-no-no., not just tonight.

245: .000

No-no-no., no-no-no.

246: .000

No-no-no., not just tonight.

247: .000

No-no-no, no-no-no (In my head., in my head).

248: .000

No-no-no., not just tonight.

249: +.500

(Were we on time?

250: .000

Should we try—)46Embed.

#drake_lyrics <- drake$Lyrics



#drake_sentences <- get_sentences(drake_lyrics)
#drake_sentiment <- sentiment(drake_sentences)
#drake_sentiment


#drake_sentimentby <- sentiment_by(drake_sentences)


#drake_positive <- filter(drake_sentiment, sentiment > 0)

#drake_positive

#drake_negative <- filter(drake_sentiment, sentiment < 0)

#drake_negative

library(magrittr)
library(dplyr)
set.seed(2)

#drakehl <- highlight(drake_sentimentby)

#drakehl
#ggplot(data = mpg) + 
#  geom_point(mapping = aes(x = displ, y = hwy, color = class))

kelly_plot <- ggplot(data = kelly_sentiment) +
	geom_point(mapping = aes(x = element_id, y = sentiment, color = word_count))

show(kelly_plot)

#knitr::include_graphics("/img/unnamed-chunk-3-1.png", error=F)
#knitr::kable("/img/unnamed-chunk-3-1.png", error=F)

kelly_plotby <- ggplot(data = kelly_sentimentby) +
	geom_point(mapping = aes(x = element_id, y = ave_sentiment, color = word_count))
show(kelly_plotby)

#staple_plot