library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.4.2
## Warning: package 'ggplot2' was built under R version 4.4.2
## Warning: package 'tibble' was built under R version 4.4.2
## Warning: package 'tidyr' was built under R version 4.4.2
## Warning: package 'readr' was built under R version 4.4.2
## Warning: package 'purrr' was built under R version 4.4.2
## Warning: package 'dplyr' was built under R version 4.4.2
## Warning: package 'stringr' was built under R version 4.4.2
## Warning: package 'forcats' was built under R version 4.4.2
## Warning: package 'lubridate' was built under R version 4.4.2
## ── 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.5.1 ✔ 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
library(dplyr)
library(datasets)
data("billboard")
billboard
## # A tibble: 317 × 79
## artist track date.entered wk1 wk2 wk3 wk4 wk5 wk6 wk7 wk8
## <chr> <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2 Pac Baby… 2000-02-26 87 82 72 77 87 94 99 NA
## 2 2Ge+her The … 2000-09-02 91 87 92 NA NA NA NA NA
## 3 3 Doors D… Kryp… 2000-04-08 81 70 68 67 66 57 54 53
## 4 3 Doors D… Loser 2000-10-21 76 76 72 69 67 65 55 59
## 5 504 Boyz Wobb… 2000-04-15 57 34 25 17 17 31 36 49
## 6 98^0 Give… 2000-08-19 51 39 34 26 26 19 2 2
## 7 A*Teens Danc… 2000-07-08 97 97 96 95 100 NA NA NA
## 8 Aaliyah I Do… 2000-01-29 84 62 51 41 38 35 35 38
## 9 Aaliyah Try … 2000-03-18 59 53 38 28 21 18 16 14
## 10 Adams, Yo… Open… 2000-08-26 76 76 74 69 68 67 61 58
## # ℹ 307 more rows
## # ℹ 68 more variables: wk9 <dbl>, wk10 <dbl>, wk11 <dbl>, wk12 <dbl>,
## # wk13 <dbl>, wk14 <dbl>, wk15 <dbl>, wk16 <dbl>, wk17 <dbl>, wk18 <dbl>,
## # wk19 <dbl>, wk20 <dbl>, wk21 <dbl>, wk22 <dbl>, wk23 <dbl>, wk24 <dbl>,
## # wk25 <dbl>, wk26 <dbl>, wk27 <dbl>, wk28 <dbl>, wk29 <dbl>, wk30 <dbl>,
## # wk31 <dbl>, wk32 <dbl>, wk33 <dbl>, wk34 <dbl>, wk35 <dbl>, wk36 <dbl>,
## # wk37 <dbl>, wk38 <dbl>, wk39 <dbl>, wk40 <dbl>, wk41 <dbl>, wk42 <dbl>, …
Dataset ini merupakan data billboard pada tahun 2000.
artist_count <- billboard %>% group_by(artist) %>% summarise(count = n())
print(artist_count, n = 228)
## # A tibble: 228 × 2
## artist count
## <chr> <int>
## 1 "2 Pac" 1
## 2 "2Ge+her" 1
## 3 "3 Doors Down" 2
## 4 "504 Boyz" 1
## 5 "98^0" 1
## 6 "A*Teens" 1
## 7 "Aaliyah" 2
## 8 "Adams, Yolanda" 1
## 9 "Adkins, Trace" 1
## 10 "Aguilera, Christina" 3
## 11 "Alice Deejay" 1
## 12 "Allan, Gary" 1
## 13 "Amber" 1
## 14 "Anastacia" 1
## 15 "Anthony, Marc" 2
## 16 "Avant" 2
## 17 "BBMak" 1
## 18 "Backstreet Boys, The" 3
## 19 "Badu, Erkyah" 1
## 20 "Baha Men" 1
## 21 "Barenaked Ladies" 1
## 22 "Beenie Man" 1
## 23 "Before Dark" 1
## 24 "Bega, Lou" 1
## 25 "Big Punisher" 1
## 26 "Black Rob" 1
## 27 "Black, Clint" 1
## 28 "Blaque" 1
## 29 "Blige, Mary J." 2
## 30 "Blink-182" 1
## 31 "Bloodhound Gang" 1
## 32 "Bon Jovi" 1
## 33 "Braxton, Toni" 3
## 34 "Brock, Chad" 2
## 35 "Brooks & Dunn" 1
## 36 "Brooks, Garth" 1
## 37 "Byrd, Tracy" 1
## 38 "Cagle, Chris" 1
## 39 "Cam'ron" 1
## 40 "Carey, Mariah" 2
## 41 "Carter, Aaron" 1
## 42 "Carter, Torrey" 1
## 43 "Changing Faces" 1
## 44 "Chesney, Kenny" 2
## 45 "Clark Family Experience" 1
## 46 "Clark, Terri" 1
## 47 "Common" 1
## 48 "Counting Crows" 1
## 49 "Creed" 2
## 50 "Cyrus, Billy Ray" 1
## 51 "D'Angelo" 2
## 52 "DMX" 3
## 53 "Da Brat" 2
## 54 "Davidson, Clay" 1
## 55 "De La Soul" 1
## 56 "Destiny's Child" 3
## 57 "Diffie, Joe" 2
## 58 "Dion, Celine" 1
## 59 "Dixie Chicks, The" 4
## 60 "Dr. Dre" 2
## 61 "Drama" 1
## 62 "Dream" 1
## 63 "Eastsidaz, The" 2
## 64 "Eiffel 65" 1
## 65 "Elliott, Missy \"Misdemeanor\"" 1
## 66 "Eminem" 3
## 67 "En Vogue" 1
## 68 "Estefan, Gloria" 1
## 69 "Evans, Sara" 1
## 70 "Eve" 2
## 71 "Everclear" 1
## 72 "Fabian, Lara" 1
## 73 "Fatboy Slim" 1
## 74 "Filter" 1
## 75 "Foo Fighters" 1
## 76 "Fragma" 1
## 77 "Funkmaster Flex" 1
## 78 "Ghostface Killah" 1
## 79 "Gill, Vince" 1
## 80 "Gilman, Billy" 1
## 81 "Ginuwine" 2
## 82 "Goo Goo Dolls" 1
## 83 "Gray, Macy" 1
## 84 "Griggs, Andy" 1
## 85 "Guy" 1
## 86 "Hanson" 1
## 87 "Hart, Beth" 1
## 88 "Heatherly, Eric" 1
## 89 "Henley, Don" 1
## 90 "Herndon, Ty" 1
## 91 "Hill, Faith" 2
## 92 "Hoku" 1
## 93 "Hollister, Dave" 1
## 94 "Hot Boys" 1
## 95 "Houston, Whitney" 4
## 96 "IMx" 1
## 97 "Ice Cube" 1
## 98 "Ideal" 1
## 99 "Iglesias, Enrique" 2
## 100 "J-Shin" 1
## 101 "Ja Rule" 1
## 102 "Jackson, Alan" 3
## 103 "Jagged Edge" 2
## 104 "Janet" 1
## 105 "Jay-Z" 5
## 106 "Jean, Wyclef" 1
## 107 "Joe" 2
## 108 "John, Elton" 1
## 109 "Jones, Donell" 1
## 110 "Jordan, Montell" 1
## 111 "Juvenile" 1
## 112 "Kandi" 1
## 113 "Keith, Toby" 2
## 114 "Kelis" 1
## 115 "Kenny G" 1
## 116 "Kid Rock" 1
## 117 "Kravitz, Lenny" 1
## 118 "Kumbia Kings" 1
## 119 "LFO" 2
## 120 "LL Cool J" 1
## 121 "Larrieux, Amel" 1
## 122 "Lawrence, Tracy" 1
## 123 "Levert, Gerald" 2
## 124 "Lil Bow Wow" 1
## 125 "Lil Wayne" 1
## 126 "Lil' Kim" 2
## 127 "Lil' Mo" 1
## 128 "Lil' Zane" 1
## 129 "Limp Bizkit" 3
## 130 "Lonestar" 3
## 131 "Lopez, Jennifer" 1
## 132 "Loveless, Patty" 1
## 133 "Lox" 1
## 134 "Lucy Pearl" 1
## 135 "Ludacris" 1
## 136 "M2M" 2
## 137 "Madison Avenue" 1
## 138 "Madonna" 2
## 139 "Martin, Ricky" 3
## 140 "Mary Mary" 1
## 141 "Master P" 1
## 142 "McBride, Martina" 2
## 143 "McEntire, Reba" 2
## 144 "McGraw, Tim" 3
## 145 "McKnight, Brian" 1
## 146 "Messina, Jo Dee" 2
## 147 "Metallica" 2
## 148 "Montgomery Gentry" 1
## 149 "Montgomery, John Michael" 1
## 150 "Moore, Chante" 1
## 151 "Moore, Mandy" 1
## 152 "Mumba, Samantha" 1
## 153 "Musiq" 1
## 154 "Mya" 2
## 155 "Mystikal" 1
## 156 "N'Sync" 3
## 157 "Nas" 1
## 158 "Nelly" 1
## 159 "Next" 1
## 160 "Nine Days" 2
## 161 "No Doubt" 1
## 162 "Nu Flavor" 1
## 163 "Offspring, The" 1
## 164 "Paisley, Brad" 2
## 165 "Papa Roach" 1
## 166 "Pearl Jam" 1
## 167 "Pink" 2
## 168 "Price, Kelly" 3
## 169 "Profyle" 1
## 170 "Puff Daddy" 1
## 171 "Q-Tip" 1
## 172 "R.E.M." 1
## 173 "Rascal Flatts" 1
## 174 "Raye, Collin" 1
## 175 "Red Hot Chili Peppers" 2
## 176 "Rimes, LeAnn" 3
## 177 "Rogers, Kenny" 1
## 178 "Ruff Endz" 1
## 179 "Sammie" 1
## 180 "Santana" 1
## 181 "Savage Garden" 2
## 182 "SheDaisy" 3
## 183 "Sheist, Shade" 1
## 184 "Shyne" 1
## 185 "Simpson, Jessica" 2
## 186 "Sisqo" 3
## 187 "Sister Hazel" 1
## 188 "Smash Mouth" 1
## 189 "Smith, Will" 1
## 190 "Son By Four" 1
## 191 "Sonique" 1
## 192 "SoulDecision" 1
## 193 "Spears, Britney" 3
## 194 "Spencer, Tracie" 1
## 195 "Splender" 1
## 196 "Sting" 1
## 197 "Stone Temple Pilots" 1
## 198 "Stone, Angie" 1
## 199 "Strait, George" 2
## 200 "Sugar Ray" 1
## 201 "TLC" 1
## 202 "Tamar" 1
## 203 "Tamia" 1
## 204 "Third Eye Blind" 2
## 205 "Thomas, Carl" 3
## 206 "Tippin, Aaron" 1
## 207 "Train" 1
## 208 "Trick Daddy" 1
## 209 "Trina" 1
## 210 "Tritt, Travis" 1
## 211 "Tuesday" 1
## 212 "Urban, Keith" 1
## 213 "Usher" 1
## 214 "Vassar, Phil" 2
## 215 "Vertical Horizon" 2
## 216 "Vitamin C" 2
## 217 "Walker, Clay" 2
## 218 "Wallflowers, The" 1
## 219 "Westlife" 1
## 220 "Williams, Robbie" 1
## 221 "Wills, Mark" 1
## 222 "Worley, Darryl" 1
## 223 "Wright, Chely" 1
## 224 "Yankee Grey" 1
## 225 "Yearwood, Trisha" 1
## 226 "Ying Yang Twins" 1
## 227 "Zombie Nation" 1
## 228 "matchbox twenty" 1
count_arrange <- artist_count %>% arrange(desc(count))
count_arrange
## # A tibble: 228 × 2
## artist count
## <chr> <int>
## 1 Jay-Z 5
## 2 Dixie Chicks, The 4
## 3 Houston, Whitney 4
## 4 Aguilera, Christina 3
## 5 Backstreet Boys, The 3
## 6 Braxton, Toni 3
## 7 DMX 3
## 8 Destiny's Child 3
## 9 Eminem 3
## 10 Jackson, Alan 3
## # ℹ 218 more rows
filter_count <- artist_count %>% filter(count > 2) %>% arrange(desc(count))
filter_count
## # A tibble: 21 × 2
## artist count
## <chr> <int>
## 1 Jay-Z 5
## 2 Dixie Chicks, The 4
## 3 Houston, Whitney 4
## 4 Aguilera, Christina 3
## 5 Backstreet Boys, The 3
## 6 Braxton, Toni 3
## 7 DMX 3
## 8 Destiny's Child 3
## 9 Eminem 3
## 10 Jackson, Alan 3
## # ℹ 11 more rows
artist_song <- billboard %>% select(artist, track, date.entered)
artist_song
## # A tibble: 317 × 3
## artist track date.entered
## <chr> <chr> <date>
## 1 2 Pac Baby Don't Cry (Keep... 2000-02-26
## 2 2Ge+her The Hardest Part Of ... 2000-09-02
## 3 3 Doors Down Kryptonite 2000-04-08
## 4 3 Doors Down Loser 2000-10-21
## 5 504 Boyz Wobble Wobble 2000-04-15
## 6 98^0 Give Me Just One Nig... 2000-08-19
## 7 A*Teens Dancing Queen 2000-07-08
## 8 Aaliyah I Don't Wanna 2000-01-29
## 9 Aaliyah Try Again 2000-03-18
## 10 Adams, Yolanda Open My Heart 2000-08-26
## # ℹ 307 more rows
track_artist <- artist_song %>% mutate(song_artist = paste(track, artist, sep =" - ")) %>% select(song_artist, date.entered)
track_artist
## # A tibble: 317 × 2
## song_artist date.entered
## <chr> <date>
## 1 Baby Don't Cry (Keep... - 2 Pac 2000-02-26
## 2 The Hardest Part Of ... - 2Ge+her 2000-09-02
## 3 Kryptonite - 3 Doors Down 2000-04-08
## 4 Loser - 3 Doors Down 2000-10-21
## 5 Wobble Wobble - 504 Boyz 2000-04-15
## 6 Give Me Just One Nig... - 98^0 2000-08-19
## 7 Dancing Queen - A*Teens 2000-07-08
## 8 I Don't Wanna - Aaliyah 2000-01-29
## 9 Try Again - Aaliyah 2000-03-18
## 10 Open My Heart - Adams, Yolanda 2000-08-26
## # ℹ 307 more rows