Skip to content

Commit

Permalink
updates to leso data and other minor changes to those chapters
Browse files Browse the repository at this point in the history
  • Loading branch information
critmcdonald committed Jul 25, 2024
1 parent f03b8a4 commit daf2535
Show file tree
Hide file tree
Showing 43 changed files with 48,350 additions and 53,871 deletions.
7 changes: 2 additions & 5 deletions billboard-cleaning.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ Since this is a new "section" of our cleaning notebook, we'll note what we are d
#| eval: false
download.file(
"https://github.com/utdata/rwd-billboard-data/blob/main/data-out/hot100_assignment_current.csv?raw=true",
"https://github.com/utdata/rwd-billboard-data/blob/main/data-out/hot100_assignment.csv?raw=true",
"data-raw/hot100_assignment.csv",
mode = "wb"
)
Expand Down Expand Up @@ -573,13 +573,10 @@ That new value could be arrived at through math or any combination of other func

```{r date-mutate}
# part we will build upon
hot100_date <- hot100_raw |> # <1>
hot100_date <- hot100_raw |> # <1>
mutate( # <2>
chart_date = mdy(chart_week) # <3>
)
# peek at the result
hot100_date |> glimpse()
```

1. At the end of the first line, we added the pipe `|>` because we are taking our `hot100` data **AND THEN** we will mutate it. (Remember *Cmd-shift-m* for the pipe!)
Expand Down
4 changes: 2 additions & 2 deletions case-when.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ leso_control <- leso_total |> # <1>
control_type = case_when( # <2>
str_detect(item_name, "AIRPLANE") ~ TRUE, # <3>
(demil_code == "A" | (demil_code == "Q" & demil_ic == 6)) ~ FALSE, # <4>
TRUE ~ TRUE # <5>
.default = TRUE # <5>
)
)
Expand All @@ -58,7 +58,7 @@ leso_control |> glimpse() # <6>
2. We mutate the data and start with the name of new column: `control_type`. We are filling that column with the result of the `case_when()` function for each row. Within the `case_when()` we are making the determination if the item is controlled or not. The left side of the `~` is the test, and the right side of `~` is what we enter into the column if the test passes. But we have more than one test:
3. The first test is we use the [`str_detect()`](https://stringr.tidyverse.org/reference/str_detect.html) function to look inside the `item_name` field looking for the term "AIRPLANE". If the test finds the term, then the `control_type` field gets a value of `TRUE` and we move to the next row. If not, it moves to the next rule to see if that is a match. (We could fill this column with any text or number we want, but we are using `TRUE` and `FALSE` because that is the most basic kind of data to keep. If the item is controlled, set the value is TRUE. If not, it should be set to FALSE.)
4. Our second rule has two complex tests and we want to mark the row FALSE if either are true. (Remember, this is based on what the DLA told me: items with A or Q6 are non-controlled.) Our `case_when()` logic first looks for the value "A" in the `demil_code` field. If it is yes, then it marks the row FALSE. If no it goes to the next part: Is there a "Q" in the `demil_code` field AND a "6" in the `demil_ic` field? Both "Q" and "6" have to be there to get marked as FALSE. If both fail, then we move to the next test.
5. The last test is our catch-all. If none of the other rules apply, then mark this row as `TRUE`, which means it is controlled. So our default in the end is to mark everything TRUE if any of the other rules don't mark it first.
5. The last test is our catch-all. If none of the other rules apply, then we set the default value as `TRUE`, which means it is controlled. So our default in the end is to mark everything TRUE if any of the other rules don't mark it first.
6. Lastly we glimpse at the data just so we can see the column was created.

As I said, there was a lot of trial and error to figure that out, but I'll show some tests here to show that we did what we were intending.
Expand Down
Binary file modified data-processed/01-hot100.rds
Binary file not shown.
Binary file modified data-processed/01-leso-all.rds
Binary file not shown.
Binary file modified data-processed/rwdir-leso-total.rds
Binary file not shown.
100 changes: 100 additions & 0 deletions data-raw/hot100_assignment.csv
Original file line number Diff line number Diff line change
Expand Up @@ -13399,6 +13399,106 @@ CHART WEEK,THIS WEEK,TITLE,PERFORMER,LAST WEEK,PEAK POS.,WKS ON CHART
7/20/2024,98,Belong Together,Mark Ambor,92,74,11
7/20/2024,99,Funny Man,Zach Bryan,0,99,1
7/20/2024,100,Okay,JT,72,72,3
7/27/2024,1,A Bar Song (Tipsy),Shaboozey,2,1,14
7/27/2024,2,I Had Some Help,Post Malone Featuring Morgan Wallen,3,1,10
7/27/2024,3,Not Like Us,Kendrick Lamar,1,1,11
7/27/2024,4,Million Dollar Baby,Tommy Richman,4,2,12
7/27/2024,5,Espresso,Sabrina Carpenter,5,3,14
7/27/2024,6,Please Please Please,Sabrina Carpenter,6,1,6
7/27/2024,7,Too Sweet,Hozier,8,1,17
7/27/2024,8,Lose Control,Teddy Swims,10,1,49
7/27/2024,9,Beautiful Things,Benson Boone,9,2,26
7/27/2024,10,Houdini,Eminem,18,2,7
7/27/2024,11,"Good Luck, Babe!",Chappell Roan,13,10,15
7/27/2024,12,Lies Lies Lies,Morgan Wallen,7,7,2
7/27/2024,13,Birds Of A Feather,Billie Eilish,11,9,9
7/27/2024,14,Cowgirls,Morgan Wallen Featuring ERNEST,15,12,31
7/27/2024,15,Pink Skies,Zach Bryan,12,6,8
7/27/2024,16,28,Zach Bryan,14,14,2
7/27/2024,17,Fortnight,Taylor Swift Featuring Post Malone,16,1,13
7/27/2024,18,Like That,"Future, Metro Boomin & Kendrick Lamar",17,1,17
7/27/2024,19,Habits,Eminem & White Gold,0,19,1
7/27/2024,20,Renaissance,Eminem,0,20,1
7/27/2024,21,Fuel,Eminem & JID,0,21,1
7/27/2024,22,Saturn,SZA,19,6,21
7/27/2024,23,Miles On It,Marshmello & Kane Brown,20,20,11
7/27/2024,24,Tobey,"Eminem, Big Sean & BabyTron",27,24,3
7/27/2024,25,Brand New Dance,Eminem,0,25,1
7/27/2024,26,Austin,Dasha,23,19,19
7/27/2024,27,Somebody Save Me,Eminem & Jelly Roll,0,27,1
7/27/2024,28,High Road,Koe Wetzel & Jessie Murph,36,27,6
7/27/2024,29,I Remember Everything,Zach Bryan Featuring Kacey Musgraves,22,1,47
7/27/2024,30,Evil,Eminem,0,30,1
7/27/2024,31,Trouble,Eminem,0,31,1
7/27/2024,32,Ain't No Love In Oklahoma,Luke Combs,31,23,9
7/27/2024,33,Pour Me A Drink,Post Malone Featuring Blake Shelton,25,12,4
7/27/2024,34,Wanna Be,GloRilla & Megan Thee Stallion,26,11,15
7/27/2024,35,We Can't Be Friends (Wait For Your Love),Ariana Grande,24,1,19
7/27/2024,36,Lunch,Billie Eilish,28,5,9
7/27/2024,37,Lucifer,Eminem & Sly Pyper,0,37,1
7/27/2024,38,Feather,Sabrina Carpenter,30,21,33
7/27/2024,39,Antichrist,Eminem,0,39,1
7/27/2024,40,Hot To Go!,Chappell Roan,39,35,7
7/27/2024,41,Si Antes Te Hubiera Conocido,Karol G,44,34,4
7/27/2024,42,Whiskey Whiskey,Moneybagg Yo Featuring Morgan Wallen,29,21,5
7/27/2024,43,I Can Do It With A Broken Heart,Taylor Swift,65,3,13
7/27/2024,44,Stick Season,Noah Kahan,37,9,42
7/27/2024,45,Guilty Conscience 2,Eminem,0,45,1
7/27/2024,46,I Am Not Okay,Jelly Roll,34,29,5
7/27/2024,47,TGIF,GloRilla,32,28,4
7/27/2024,48,Lovin On Me,Jack Harlow,35,1,36
7/27/2024,49,Slow It Down,Benson Boone,42,34,17
7/27/2024,50,Yeah Glo!,GloRilla,38,28,23
7/27/2024,51,Mamushi,Megan Thee Stallion Featuring Yuki Chiba,45,45,3
7/27/2024,52,You Look Like You Love Me,Ella Langley Featuring Riley Green,40,36,4
7/27/2024,53,Gata Only,FloyyMenor X Cris Mj,43,27,18
7/27/2024,54,Bulletproof,Nate Smith,51,37,15
7/27/2024,55,Stargazing,Myles Smith,47,41,10
7/27/2024,56,Temporary,Eminem & Skylar Grey,0,56,1
7/27/2024,57,American Nights,Zach Bryan,21,21,2
7/27/2024,58,Devil Is A Lie,Tommy Richman,41,32,5
7/27/2024,59,Road Rage,"Eminem, Dem Jointz & Sly Pyper",0,59,1
7/27/2024,60,Tough,Quavo & Lana Del Rey,33,33,2
7/27/2024,61,Dirt Cheap,Cody Johnson,50,43,13
7/27/2024,62,Did It First,Ice Spice & Central Cee,0,62,1
7/27/2024,63,Woman's World,Katy Perry,0,63,1
7/27/2024,64,BAND4BAND,Central Cee & Lil Baby,53,18,8
7/27/2024,65,Red Wine Supernova,Chappell Roan,55,46,7
7/27/2024,66,Pink Pony Club,Chappell Roan,59,56,5
7/27/2024,67,Illusion,Dua Lipa,63,43,14
7/27/2024,68,Kehlani,Jordan Adetunji,62,52,4
7/27/2024,69,Bad One,Eminem & White Gold,0,69,1
7/27/2024,70,Get It Sexyy,Sexyy Red,52,20,18
7/27/2024,71,Nights Like This,The Kid LAROI,54,47,4
7/27/2024,72,Head Honcho,Eminem & Ez Mil,0,72,1
7/27/2024,73,I Like The Way You Kiss Me,Artemas,64,12,17
7/27/2024,74,Type Shit,"Future, Metro Boomin, Travis Scott & Playboi Carti",66,2,17
7/27/2024,75,Euphoria,Kendrick Lamar,60,3,12
7/27/2024,76,One Of Wun,Gunna,72,26,10
7/27/2024,77,Chihiro,Billie Eilish,70,12,9
7/27/2024,78,360,Charli XCX,79,73,6
7/27/2024,79,We Ride,Bryan Martin,56,56,15
7/27/2024,80,Nasty,Tinashe,67,61,7
7/27/2024,81,The Door,Teddy Swims,80,76,7
7/27/2024,82,The Boy Is Mine,Ariana Grande,68,16,11
7/27/2024,83,Wind Up Missin' You,Tucker Wetmore,75,63,16
7/27/2024,84,Better Days,Zach Bryan Featuring John Mayer,46,46,2
7/27/2024,85,Wildflower,Billie Eilish,85,17,9
7/27/2024,86,PJ,BossMan DLow & Lil Baby,0,86,1
7/27/2024,87,U My Everything,Sexyy Red & Drake,76,44,8
7/27/2024,88,Scared To Start,Michael Marcagi,81,54,22
7/27/2024,89,Si No Quieres No,Luis R Conriquez x Neton Vega,82,53,11
7/27/2024,90,Casual,Chappell Roan,90,82,4
7/27/2024,91,Indifferent,Megan Moroney,0,91,1
7/27/2024,92,Chevrolet,Dustin Lynch Featuring Jelly Roll,89,89,5
7/27/2024,93,Girls,The Kid LAROI,77,51,3
7/27/2024,94,Hang Tight Honey,Lainey Wilson,86,86,5
7/27/2024,95,Oak Island,Zach Bryan,48,48,2
7/27/2024,96,Bass Boat,Zach Bryan,61,61,2
7/27/2024,97,Think I'm In Love With You,Chris Stapleton,87,49,11
7/27/2024,98,Beautiful As You,Thomas Rhett,95,83,6
7/27/2024,99,Sweet Dreams,Koe Wetzel,88,35,9
7/27/2024,100,Sandpaper,Zach Bryan Featuring Bruce Springsteen,71,71,2
8/4/1958,1,Poor Little Fool,Ricky Nelson,NA,1,1
8/4/1958,2,Patricia,Perez Prado And His Orchestra,NA,2,1
8/4/1958,3,Splish Splash,Bobby Darin,NA,3,1
Expand Down
Loading

0 comments on commit daf2535

Please sign in to comment.