Libraries
library(readr)
library(ggplot2)
library(tidyr)
## Warning: package 'tidyr' was built under R version 4.2.3
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
Import dataset
spotify2023 <- read_csv("C:/Users/hp/Downloads/spotify2023 (1).csv")
## Rows: 953 Columns: 24
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (5): track_name, artist(s)_name, streams, key, mode
## dbl (17): artist_count, released_year, released_month, released_day, in_spot...
## num (2): in_deezer_playlists, in_shazam_charts
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Making copy of dataset
spotify <- spotify2023
dim(spotify)
## [1] 953 24
head(spotify)
## # A tibble: 6 × 24
## track_name artis…¹ artis…² relea…³ relea…⁴ relea…⁵ in_sp…⁶ in_sp…⁷ streams
## <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr>
## 1 Seven (feat. … Latto,… 2 2023 7 14 553 147 141381…
## 2 LALA Myke T… 1 2023 3 23 1474 48 133716…
## 3 vampire Olivia… 1 2023 6 30 1397 113 140003…
## 4 Cruel Summer Taylor… 1 2019 8 23 7858 100 800840…
## 5 WHERE SHE GOES Bad Bu… 1 2023 5 18 3133 50 303236…
## 6 Sprinter Dave, … 2 2023 6 1 2186 91 183706…
## # … with 15 more variables: in_apple_playlists <dbl>, in_apple_charts <dbl>,
## # in_deezer_playlists <dbl>, in_deezer_charts <dbl>, in_shazam_charts <dbl>,
## # bpm <dbl>, key <chr>, mode <chr>, `danceability_%` <dbl>,
## # `valence_%` <dbl>, `energy_%` <dbl>, `acousticness_%` <dbl>,
## # `instrumentalness_%` <dbl>, `liveness_%` <dbl>, `speechiness_%` <dbl>, and
## # abbreviated variable names ¹`artist(s)_name`, ²artist_count,
## # ³released_year, ⁴released_month, ⁵released_day, ⁶in_spotify_playlists, …
Structure and summary of dataset
str(spotify)
## spc_tbl_ [953 × 24] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
## $ track_name : chr [1:953] "Seven (feat. Latto) (Explicit Ver.)" "LALA" "vampire" "Cruel Summer" ...
## $ artist(s)_name : chr [1:953] "Latto, Jung Kook" "Myke Towers" "Olivia Rodrigo" "Taylor Swift" ...
## $ artist_count : num [1:953] 2 1 1 1 1 2 2 1 1 2 ...
## $ released_year : num [1:953] 2023 2023 2023 2019 2023 ...
## $ released_month : num [1:953] 7 3 6 8 5 6 3 7 5 3 ...
## $ released_day : num [1:953] 14 23 30 23 18 1 16 7 15 17 ...
## $ in_spotify_playlists: num [1:953] 553 1474 1397 7858 3133 ...
## $ in_spotify_charts : num [1:953] 147 48 113 100 50 91 50 43 83 44 ...
## $ streams : chr [1:953] "141381703" "133716286" "140003974" "800840817" ...
## $ in_apple_playlists : num [1:953] 43 48 94 116 84 67 34 25 60 49 ...
## $ in_apple_charts : num [1:953] 263 126 207 207 133 213 222 89 210 110 ...
## $ in_deezer_playlists : num [1:953] 45 58 91 125 87 88 43 30 48 66 ...
## $ in_deezer_charts : num [1:953] 10 14 14 12 15 17 13 13 11 13 ...
## $ in_shazam_charts : num [1:953] 826 382 949 548 425 946 418 194 953 339 ...
## $ bpm : num [1:953] 125 92 138 170 144 141 148 100 130 170 ...
## $ key : chr [1:953] "B" "C#" "F" "A" ...
## $ mode : chr [1:953] "Major" "Major" "Major" "Major" ...
## $ danceability_% : num [1:953] 80 71 51 55 65 92 67 67 85 81 ...
## $ valence_% : num [1:953] 89 61 32 58 23 66 83 26 22 56 ...
## $ energy_% : num [1:953] 83 74 53 72 80 58 76 71 62 48 ...
## $ acousticness_% : num [1:953] 31 7 17 11 14 19 48 37 12 21 ...
## $ instrumentalness_% : num [1:953] 0 0 0 0 63 0 0 0 0 0 ...
## $ liveness_% : num [1:953] 8 10 31 11 11 8 8 11 28 8 ...
## $ speechiness_% : num [1:953] 4 4 6 15 6 24 3 4 9 33 ...
## - attr(*, "spec")=
## .. cols(
## .. track_name = col_character(),
## .. `artist(s)_name` = col_character(),
## .. artist_count = col_double(),
## .. released_year = col_double(),
## .. released_month = col_double(),
## .. released_day = col_double(),
## .. in_spotify_playlists = col_double(),
## .. in_spotify_charts = col_double(),
## .. streams = col_character(),
## .. in_apple_playlists = col_double(),
## .. in_apple_charts = col_double(),
## .. in_deezer_playlists = col_number(),
## .. in_deezer_charts = col_double(),
## .. in_shazam_charts = col_number(),
## .. bpm = col_double(),
## .. key = col_character(),
## .. mode = col_character(),
## .. `danceability_%` = col_double(),
## .. `valence_%` = col_double(),
## .. `energy_%` = col_double(),
## .. `acousticness_%` = col_double(),
## .. `instrumentalness_%` = col_double(),
## .. `liveness_%` = col_double(),
## .. `speechiness_%` = col_double()
## .. )
## - attr(*, "problems")=<externalptr>
summary(spotify)
## track_name artist(s)_name artist_count released_year
## Length:953 Length:953 Min. :1.000 Min. :1930
## Class :character Class :character 1st Qu.:1.000 1st Qu.:2020
## Mode :character Mode :character Median :1.000 Median :2022
## Mean :1.556 Mean :2018
## 3rd Qu.:2.000 3rd Qu.:2022
## Max. :8.000 Max. :2023
##
## released_month released_day in_spotify_playlists in_spotify_charts
## Min. : 1.000 Min. : 1.00 Min. : 31 Min. : 0.00
## 1st Qu.: 3.000 1st Qu.: 6.00 1st Qu.: 875 1st Qu.: 0.00
## Median : 6.000 Median :13.00 Median : 2224 Median : 3.00
## Mean : 6.034 Mean :13.93 Mean : 5200 Mean : 12.01
## 3rd Qu.: 9.000 3rd Qu.:22.00 3rd Qu.: 5542 3rd Qu.: 16.00
## Max. :12.000 Max. :31.00 Max. :52898 Max. :147.00
##
## streams in_apple_playlists in_apple_charts in_deezer_playlists
## Length:953 Min. : 0.00 Min. : 0.00 Min. : 0.0
## Class :character 1st Qu.: 13.00 1st Qu.: 7.00 1st Qu.: 13.0
## Mode :character Median : 34.00 Median : 38.00 Median : 44.0
## Mean : 67.81 Mean : 51.91 Mean : 385.2
## 3rd Qu.: 88.00 3rd Qu.: 87.00 3rd Qu.: 164.0
## Max. :672.00 Max. :275.00 Max. :12367.0
##
## in_deezer_charts in_shazam_charts bpm key
## Min. : 0.000 Min. : 0 Min. : 65.0 Length:953
## 1st Qu.: 0.000 1st Qu.: 0 1st Qu.:100.0 Class :character
## Median : 0.000 Median : 2 Median :121.0 Mode :character
## Mean : 2.666 Mean : 60 Mean :122.5
## 3rd Qu.: 2.000 3rd Qu.: 37 3rd Qu.:140.0
## Max. :58.000 Max. :1451 Max. :206.0
## NA's :50
## mode danceability_% valence_% energy_%
## Length:953 Min. :23.00 Min. : 4.00 Min. : 9.00
## Class :character 1st Qu.:57.00 1st Qu.:32.00 1st Qu.:53.00
## Mode :character Median :69.00 Median :51.00 Median :66.00
## Mean :66.97 Mean :51.43 Mean :64.28
## 3rd Qu.:78.00 3rd Qu.:70.00 3rd Qu.:77.00
## Max. :96.00 Max. :97.00 Max. :97.00
##
## acousticness_% instrumentalness_% liveness_% speechiness_%
## Min. : 0.00 Min. : 0.000 Min. : 3.00 Min. : 2.00
## 1st Qu.: 6.00 1st Qu.: 0.000 1st Qu.:10.00 1st Qu.: 4.00
## Median :18.00 Median : 0.000 Median :12.00 Median : 6.00
## Mean :27.06 Mean : 1.581 Mean :18.21 Mean :10.13
## 3rd Qu.:43.00 3rd Qu.: 0.000 3rd Qu.:24.00 3rd Qu.:11.00
## Max. :97.00 Max. :91.000 Max. :97.00 Max. :64.00
##
Checking NULL values
colSums(is.na(spotify))
## track_name artist(s)_name artist_count
## 0 0 0
## released_year released_month released_day
## 0 0 0
## in_spotify_playlists in_spotify_charts streams
## 0 0 0
## in_apple_playlists in_apple_charts in_deezer_playlists
## 0 0 0
## in_deezer_charts in_shazam_charts bpm
## 0 50 0
## key mode danceability_%
## 95 0 0
## valence_% energy_% acousticness_%
## 0 0 0
## instrumentalness_% liveness_% speechiness_%
## 0 0 0
Getting percentage of null values and replacing it with 0
missing_percent <- (colSums(is.na(spotify)) / nrow(spotify)) * 100
print(missing_percent)
## track_name artist(s)_name artist_count
## 0.00000 0.00000 0.00000
## released_year released_month released_day
## 0.00000 0.00000 0.00000
## in_spotify_playlists in_spotify_charts streams
## 0.00000 0.00000 0.00000
## in_apple_playlists in_apple_charts in_deezer_playlists
## 0.00000 0.00000 0.00000
## in_deezer_charts in_shazam_charts bpm
## 0.00000 5.24659 0.00000
## key mode danceability_%
## 9.96852 0.00000 0.00000
## valence_% energy_% acousticness_%
## 0.00000 0.00000 0.00000
## instrumentalness_% liveness_% speechiness_%
## 0.00000 0.00000 0.00000
spotify$in_shazam_charts[is.na(spotify$in_shazam_charts)] <- 0
spotify$key[is.na(spotify$key)] <- 0
Checking missing values
missing_values <- colSums(is.na(spotify))
print(missing_values)
## track_name artist(s)_name artist_count
## 0 0 0
## released_year released_month released_day
## 0 0 0
## in_spotify_playlists in_spotify_charts streams
## 0 0 0
## in_apple_playlists in_apple_charts in_deezer_playlists
## 0 0 0
## in_deezer_charts in_shazam_charts bpm
## 0 0 0
## key mode danceability_%
## 0 0 0
## valence_% energy_% acousticness_%
## 0 0 0
## instrumentalness_% liveness_% speechiness_%
## 0 0 0
Convert ‘streams’ column to numeric with ‘NA’ for non-convertible values
spotify$streams_numeric <- as.numeric(spotify$streams)
## Warning: NAs introduced by coercion
spotify$streams_numeric
## [1] 141381703 133716286 140003974 800840817 303236322 183706234
## [7] 725980112 58149378 95217315 553634067 505671438 58255150
## [13] 1316855716 387570742 2513188493 1163093654 496795686 30546883
## [19] 335222234 363369738 86444842 52135248 1297026226 200647221
## [25] 115364561 78300654 899183384 61245289 429829812 127408954
## [31] 22581161 52294266 843957510 999748277 618990393 123122413
## [37] 188933502 1355959075 786181836 176553476 354495408 2808096550
## [43] 1109433169 1047101291 65156199 570515054 1085685420 1647990401
## [49] 2565529693 518745108 107753850 177740666 153372011 57876440
## [55] 1813673666 3703895074 256483385 1214083358 16011326 812019557
## [61] 111947664 156338624 720434240 357925728 674072710 1755214421
## [67] 404562836 373199958 14780425 39578178 54266102 2557975762
## [73] 751134527 2282771485 1356565093 1592909789 635412045 1230675890
## [79] 585695368 43857627 2009094673 600976848 39709092 39228929
## [85] 2665343922 223633238 2887241814 1440757818 165484133 58054811
## [91] 157058870 95131998 250305248 685032533 38411956 144565150
## [97] 127567540 399686758 983637508 118482347 882831184 286400165
## [103] 172825906 1241559043 29562220 77309611 1605224506 1116995633
## [109] 838079900 1163620694 1093605526 179659294 39058561 36912123
## [115] 1205951614 1791000570 201660859 248088961 90839753 607123776
## [121] 55842345 211050784 342897938 2762 330346424 601863821
## [127] 1953533826 2322580122 2355719893 66902503 96273746 430977451
## [133] 284819874 721975598 1217120710 109276132 276259178 54225632
## [139] 2559529074 681583126 2594040133 81102253 11956641 1687664027
## [145] 11599388 611700552 1133865788 1089402494 411747614 255932395
## [151] 31873544 95053634 1279434863 233801632 1481349984 142095275
## [157] 618885532 2011464183 1167330737 929964809 436027885 657723613
## [163] 2713922350 621660989 1591223784 950906471 1593270737 1410088830
## [169] 1235005533 1661187319 1374581173 94186466 1788326445 1840364617
## [175] 143573775 684675814 1113838873 1267333350 726307468 3562543890
## [181] 1131090940 307370144 1271293243 265882712 841749534 47956378
## [187] 806397070 2132335812 1641426668 2135158446 367316268 350381515
## [193] 1264310836 30343206 405136812 1145727611 540654286 57312735
## [199] 397582059 1479115056 86773632 133753727 123124076 463564958
## [205] 64533040 65496046 68616963 161460990 70106975 113509496
## [211] 89933133 71007139 43522589 232896922 37126685 195576623
## [217] 532336353 538115192 46142772 401036314 127026613 345031710
## [223] 288101651 60350538 335074782 76767396 46065667 459276435
## [229] 39666245 138517666 822633917 595900742 51985779 57945987
## [235] 115010040 175097833 57089066 488386797 32761689 1047480053
## [241] 153454328 217672943 457184829 939844851 726434358 573633020
## [247] 1406111294 71573339 24975653 145458418 1424589568 231332117
## [253] 415932686 988515741 50847624 39893489 92035115 118810253
## [259] 77233241 206399629 117747907 266624541 293186992 139681964
## [265] 123132751 103762518 162887075 91221625 190490915 96180277
## [271] 185240616 885093467 104992946 147290338 1302184087 158950978
## [277] 76910644 137123880 782369383 502574952 207033255 404887295
## [283] 381161027 466231982 357580552 61105704 198275403 168448603
## [289] 705469769 34502215 482175240 304118600 1449799467 173627354
## [295] 90025258 652704649 1829992958 655466831 146409671 95816024
## [301] 117206995 100409613 80758350 325592432 58473276 52722996
## [307] 191945597 77377503 743693613 267789608 1221813483 449701773
## [313] 67070410 116334601 433356509 165584767 367814306 477033549
## [319] 156214700 448843705 1357608774 294352144 972164968 920045682
## [325] 2420461338 1947371785 244658767 68216992 223582566 471819764
## [331] 272377463 1361425037 149778242 116599790 148469433 497225336
## [337] 88791109 125917280 105062254 95623148 144584800 298063749
## [343] 166570053 83021468 139836056 303216294 221409663 58890931
## [349] 81419389 156777415 284908316 93438910 363472647 372476382
## [355] 380726517 56533272 175399345 203221468 1624165576 134294498
## [361] 70069745 609293408 671365962 362361576 93587665 1223481149
## [367] 1022258230 263453310 1435127549 236857112 147538971 698086140
## [373] 723894473 34450974 403097450 309483971 319566866 909001996
## [379] 1061966512 32526947 124988687 103787664 134255790 301051721
## [385] 156338624 152850295 309653982 297328960 332506354 480507035
## [391] 1065580332 122763672 445763624 1365184 184308753 789753877
## [397] 323358833 606361689 120972253 338564981 1606986953 1301799902
## [403] 140187018 1897517891 107642809 551305895 556585270 2303033973
## [409] 646886885 222612678 1814349763 872137015 571386359 304079786
## [415] 174006928 284785823 163284000 246390068 482257456 168684524
## [421] 78489819 195516622 1260594497 428685680 1024858327 838586769
## [427] 199386237 972509632 213438580 1555511105 210038833 227918678
## [433] 826623384 1802514301 1329090101 181831132 462791599 348647203
## [439] 366599607 90598517 1479264469 1449779435 1159176109 769213520
## [445] 741301563 807561936 834129063 663832097 446390129 690104769
## [451] 485285717 520034544 476244795 629173063 404664135 98709329
## [457] 110849052 460492795 94005786 395591396 389771964 403939487
## [463] 481697415 110073250 88092256 351636786 473248298 73981293
## [469] 155653938 395591396 429504768 242767149 65362788 67540165
## [475] 62019074 135723538 295998468 261116938 136689549 135611421
## [481] 356709897 110649992 301869854 127027715 57144458 56870689
## [487] 323437194 317726339 116144341 328207708 608228647 180577478
## [493] 809306935 49262961 614555082 245350949 178660459 51641685
## [499] 78139948 322336177 1007612429 326792833 391251368 349585590
## [505] 339659802 674772936 432719968 1309887447 119238316 116903579
## [511] 888046992 200660871 130655803 1887039593 88103848 101114984
## [517] 1575467011 91656026 1042568408 1735441776 726837877 53933526
## [523] 267758538 74601456 920797189 539595276 1367810478 578207856
## [529] 775542072 863625566 656013912 1056760045 611994237 1230855859
## [535] 582981380 1858144199 240684449 583687007 63803529 466214729
## [541] 236940480 41924466 225259194 393230256 287201015 599770206
## [547] 342779426 673801126 1168642797 540539717 383550148 530511203
## [553] 37307967 510876816 1445941661 1763363713 374191487 108809090
## [559] 436695353 421040617 501541661 354065229 1143647827 311395144
## [565] 672656250 1256880657 1692897992 245095641 686734357 261414174
## [571] 610045621 1115880852 594482982 566954746 NA 374706940
## [577] 184937148 31959571 167076418 824420218 363467642 1127468248
## [583] 60680939 247737946 1699402402 154797871 198883004 124407432
## [589] 850608354 376333030 516784627 1608045237 506778838 1472799873
## [595] 513643924 261286503 783706581 422691058 1062345656 1252563873
## [601] 851070493 263894529 345903614 951637566 956865266 427486004
## [607] 156658366 624515457 777765388 412795151 1138474110 355219175
## [613] 290228626 1062956628 1180094974 1456081449 432702334 489945871
## [619] 465959382 1223481149 2864791672 2288695111 720825549 2086124197
## [625] 1690192927 991336132 593917618 200972675 71014967 560222750
## [631] 1806617704 77337771 528544703 865640097 2159346687 211372494
## [637] 651732901 608334048 863756573 797402345 1695712020 1759567999
## [643] 223319934 54937991 226897599 258316038 596152090 177129919
## [649] 716591492 1210599487 246376690 496311364 146789379 843309044
## [655] 500340342 107255472 135079152 822239726 1202722675 343197054
## [661] 240769997 426204830 421135627 554875730 467727006 327498031
## [667] 185408548 245400167 579395142 675039469 252871192 231996128
## [673] 1929770265 918915401 1180896317 498960285 685071800 258714692
## [679] 143139338 209768491 64714573 50746620 154119539 181328253
## [685] 370068639 2280566092 563902868 317622165 291709698 203680270
## [691] 81350745 282883169 64787943 2484812918 461437791 1439191367
## [697] 759208783 368646862 299634472 756907987 682475162 546191065
## [703] 229473310 202677468 121913181 208166039 527033089 94616487
## [709] 394030335 193443895 299648208 182978249 319757142 109091573
## [715] 153240879 346127840 312622938 2197010679 1200808494 797196073
## [721] 1970673297 665765558 263779030 339473453 2204080728 2591224264
## [727] 135444283 1457139296 236872197 694525298 240661097 421365166
## [733] 349746291 255120451 190981339 924193303 305771063 273005485
## [739] 89566512 677389855 75476209 408843328 187772591 178512385
## [745] 101780047 118381354 146363130 126443991 157990698 176290831
## [751] 1023187129 106933107 139193812 212234990 1714490998 197643795
## [757] 807015863 933815613 499710590 120847157 53909146 2236667932
## [763] 2123309722 301242089 723894473 237351106 461558540 417230415
## [769] 156898322 127309180 313113297 173702135 271666301 305650299
## [775] 123216717 479655659 126191104 344055883 338422004 68895644
## [781] 86176890 403231558 319546754 61739839 283359161 76831876
## [787] 283332261 307752576 279737940 212351890 1304313953 150500965
## [793] 246127838 582863434 58687425 212109195 382199619 41210087
## [799] 231657891 53729194 244741137 42485571 37778188 254218729
## [805] 53603447 160035717 164163229 37091576 284249832 33381454
## [811] 184622518 300983101 121077868 106919680 136996305 65719930
## [817] 229497852 185550869 54682594 240580042 1284942608 71423324
## [823] 244891912 132171975 184706613 184826429 302006641 330881149
## [829] 334733572 366214458 114546317 290833204 448500832 136676504
## [835] 190625045 79095270 273194684 333146475 194902696 311482393
## [841] 195918494 248511839 233671263 199587884 91781263 383835984
## [847] 236060709 189236868 160845341 588955257 238350348 187703102
## [853] 295307001 138334433 445590495 286739476 1122364376 157136970
## [859] 137070925 183273246 184807630 164856284 704171068 354614964
## [865] 279717388 195628667 221752937 263280370 213505179 130419412
## [871] 155795783 1553497987 293466523 711366595 191448892 85924992
## [877] 176103902 121189256 131746175 244790012 129314708 331511413
## [883] 219196651 170732845 273914335 179061440 185236961 171788484
## [889] 387080183 264717480 244928911 97610446 287278853 887906111
## [895] 123473120 295152154 323455692 240918092 191873381 284216603
## [901] 239411309 265548837 703301727 244585109 189476119 277132266
## [907] 278920007 222410722 185392587 202452860 1608164312 624101957
## [913] 148461629 47093942 380319238 209106362 53987404 115331792
## [919] 225093344 84697729 159240673 170709584 154356956 723043854
## [925] 247689123 176474912 235549288 140430339 85559365 146223492
## [931] 187701588 154863153 191333656 253650850 223064273 170413877
## [937] 218320587 141720999 187339835 198365537 186104310 177503916
## [943] 71095708 112436403 203436468 93367537 106249219 181382590
## [949] 91473363 121871870 73513683 133895612 96007391
Finding non-numeric rows and dropping them at the indexes
non_numeric_rows <- spotify[is.na(spotify$streams_numeric),]
non_numeric_rows
## # A tibble: 1 × 25
## track_name artis…¹ artis…² relea…³ relea…⁴ relea…⁵ in_sp…⁶ in_sp…⁷ streams
## <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr>
## 1 Love Grows (W… Edison… 1 1970 1 1 2877 0 BPM110…
## # … with 16 more variables: in_apple_playlists <dbl>, in_apple_charts <dbl>,
## # in_deezer_playlists <dbl>, in_deezer_charts <dbl>, in_shazam_charts <dbl>,
## # bpm <dbl>, key <chr>, mode <chr>, `danceability_%` <dbl>,
## # `valence_%` <dbl>, `energy_%` <dbl>, `acousticness_%` <dbl>,
## # `instrumentalness_%` <dbl>, `liveness_%` <dbl>, `speechiness_%` <dbl>,
## # streams_numeric <dbl>, and abbreviated variable names ¹`artist(s)_name`,
## # ²artist_count, ³released_year, ⁴released_month, ⁵released_day, …
spotify <- spotify[-575, ]
Resetting row indexes and checking dataset
spotify <- spotify[ , , drop = FALSE]
dim(spotify)
## [1] 952 25
Converting “Streams” column to a numeric type integer
spotify$streams <- as.integer(spotify$streams)
## Warning: NAs introduced by coercion to integer range
print(class(spotify$streams))
## [1] "integer"
Top 10 most streamed Tracks
# Sorting dataset by the 'streams' column in descending order
spotify <- spotify[order(-spotify$streams), ]
# Selecting top 10
top_10_songs <- head(spotify, 10)
head(spotify,10)
## # A tibble: 10 × 25
## track_name artis…¹ artis…² relea…³ relea…⁴ relea…⁵ in_sp…⁶ in_sp…⁷ streams
## <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
## 1 Take Me To C… Hozier 1 2013 9 13 23804 31 2.14e9
## 2 Circles Post M… 1 2019 8 30 19664 16 2.13e9
## 3 Love Yourself Justin… 1 2015 11 9 22730 5 2.12e9
## 4 All of Me John L… 1 2013 8 1 27221 0 2.09e9
## 5 Counting Sta… OneRep… 1 2013 1 1 29215 43 2.01e9
## 6 Riptide Vance … 1 1975 1 1 31123 55 2.01e9
## 7 Wake Me Up -… Avicii 1 2013 1 1 50887 34 1.97e9
## 8 Can't Hold U… Ray Da… 3 2011 8 16 6074 52 1.95e9
## 9 The Hills The We… 1 2015 5 27 25744 4 1.95e9
## 10 HUMBLE. Kendri… 1 2017 3 30 33206 1 1.93e9
## # … with 16 more variables: in_apple_playlists <dbl>, in_apple_charts <dbl>,
## # in_deezer_playlists <dbl>, in_deezer_charts <dbl>, in_shazam_charts <dbl>,
## # bpm <dbl>, key <chr>, mode <chr>, `danceability_%` <dbl>,
## # `valence_%` <dbl>, `energy_%` <dbl>, `acousticness_%` <dbl>,
## # `instrumentalness_%` <dbl>, `liveness_%` <dbl>, `speechiness_%` <dbl>,
## # streams_numeric <dbl>, and abbreviated variable names ¹`artist(s)_name`,
## # ²artist_count, ³released_year, ⁴released_month, ⁵released_day, …
# Reseting row indexes
top_10_songs <- top_10_songs[ , , drop = FALSE]
print(top_10_songs)
## # A tibble: 10 × 25
## track_name artis…¹ artis…² relea…³ relea…⁴ relea…⁵ in_sp…⁶ in_sp…⁷ streams
## <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
## 1 Take Me To C… Hozier 1 2013 9 13 23804 31 2.14e9
## 2 Circles Post M… 1 2019 8 30 19664 16 2.13e9
## 3 Love Yourself Justin… 1 2015 11 9 22730 5 2.12e9
## 4 All of Me John L… 1 2013 8 1 27221 0 2.09e9
## 5 Counting Sta… OneRep… 1 2013 1 1 29215 43 2.01e9
## 6 Riptide Vance … 1 1975 1 1 31123 55 2.01e9
## 7 Wake Me Up -… Avicii 1 2013 1 1 50887 34 1.97e9
## 8 Can't Hold U… Ray Da… 3 2011 8 16 6074 52 1.95e9
## 9 The Hills The We… 1 2015 5 27 25744 4 1.95e9
## 10 HUMBLE. Kendri… 1 2017 3 30 33206 1 1.93e9
## # … with 16 more variables: in_apple_playlists <dbl>, in_apple_charts <dbl>,
## # in_deezer_playlists <dbl>, in_deezer_charts <dbl>, in_shazam_charts <dbl>,
## # bpm <dbl>, key <chr>, mode <chr>, `danceability_%` <dbl>,
## # `valence_%` <dbl>, `energy_%` <dbl>, `acousticness_%` <dbl>,
## # `instrumentalness_%` <dbl>, `liveness_%` <dbl>, `speechiness_%` <dbl>,
## # streams_numeric <dbl>, and abbreviated variable names ¹`artist(s)_name`,
## # ²artist_count, ³released_year, ⁴released_month, ⁵released_day, …
Barplot of Top 10 Tracks
ggplot(data = top_10_songs, aes(x = streams, y = reorder(track_name, streams))) +
geom_bar(stat = "identity", fill = "#FFA500") +
labs(x = "Streams", y = "Track name", title = "Top 10 Songs by Streams") +
theme_minimal() +
theme(axis.text.y = element_text(hjust = 1)) +
scale_x_continuous(labels = scales::label_number(scale = 1e-9, suffix = "B"))
Changing column name from artist(s)_name to artist_name
colnames(spotify)[2] = "artist_name"
Splitting and exploding Artist name
spotify$artist_name <- strsplit(spotify$artist_name, ',')
spotify <- spotify %>%
unnest(artist_name)
rownames(spotify) <- NULL
Dropping Artist Count column
spotify <- spotify %>%
select(-artist_count)
Searching and deleting duplicate rows
duplicated_rows <- spotify[duplicated(spotify) | duplicated(spotify, fromLast = TRUE), ]
print(duplicated_rows)
## # A tibble: 2 × 24
## track_name artis…¹ relea…² relea…³ relea…⁴ in_sp…⁵ in_sp…⁶ streams in_ap…⁷
## <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <int> <dbl>
## 1 Fingers Cross… " Laur… 2022 1 5 2235 0 3.50e8 65
## 2 Fingers Cross… " Laur… 2022 1 5 2235 0 3.50e8 65
## # … with 15 more variables: in_apple_charts <dbl>, in_deezer_playlists <dbl>,
## # in_deezer_charts <dbl>, in_shazam_charts <dbl>, bpm <dbl>, key <chr>,
## # mode <chr>, `danceability_%` <dbl>, `valence_%` <dbl>, `energy_%` <dbl>,
## # `acousticness_%` <dbl>, `instrumentalness_%` <dbl>, `liveness_%` <dbl>,
## # `speechiness_%` <dbl>, streams_numeric <dbl>, and abbreviated variable
## # names ¹artist_name, ²released_year, ³released_month, ⁴released_day,
## # ⁵in_spotify_playlists, ⁶in_spotify_charts, ⁷in_apple_playlists
spotify <- spotify[!duplicated(spotify), ]
# Reset the row indexes
rownames(spotify) <- NULL
# Rechecking dupes
duplicated_rows <- spotify[duplicated(spotify), ]
print(duplicated_rows)
## # A tibble: 0 × 24
## # … with 24 variables: track_name <chr>, artist_name <chr>,
## # released_year <dbl>, released_month <dbl>, released_day <dbl>,
## # in_spotify_playlists <dbl>, in_spotify_charts <dbl>, streams <int>,
## # in_apple_playlists <dbl>, in_apple_charts <dbl>, in_deezer_playlists <dbl>,
## # in_deezer_charts <dbl>, in_shazam_charts <dbl>, bpm <dbl>, key <chr>,
## # mode <chr>, danceability_% <dbl>, valence_% <dbl>, energy_% <dbl>,
## # acousticness_% <dbl>, instrumentalness_% <dbl>, liveness_% <dbl>, …
Top 10 Streamed Artists
Sum of Streams by artist
artist_streams <- aggregate(streams ~ artist_name, data = spotify, sum)
Sorting in descending and selecting top 10
artist_streams <- artist_streams[order(-artist_streams$streams), ]
top_10_most_streamed <- head(artist_streams, 10)
# Printing top 10 most streamed artists and total streams
for (i in 1:nrow(top_10_most_streamed)) {
artist <- top_10_most_streamed$artist_name[i]
streams <- top_10_most_streamed$streams[i]
cat(artist, ": ", streams, " total streams\n")
}
## Bad Bunny : 15363784442 total streams
## The Weeknd : 15247121149 total streams
## Taylor Swift : 14423238266 total streams
## Eminem : 10193727260 total streams
## Bad Bunny : 8449742828 total streams
## Olivia Rodrigo : 7442148916 total streams
## Bruno Mars : 7346351599 total streams
## Harry Styles : 6772877034 total streams
## SZA : 6493011189 total streams
## Arctic Monkeys : 5569806731 total streams
BarGraph for Top 10 most streamed artist
most_streamed_artist <- top_10_most_streamed %>%
data.frame(artist = rownames(.), streams = .)
most_streamed_artist
## artist streams.artist_name streams.streams
## 368 368 Bad Bunny 15363784442
## 745 745 The Weeknd 15247121149
## 733 733 Taylor Swift 14423238266
## 454 454 Eminem 10193727260
## 37 37 Bad Bunny 8449742828
## 640 640 Olivia Rodrigo 7442148916
## 391 391 Bruno Mars 7346351599
## 484 484 Harry Styles 6772877034
## 728 728 SZA 6493011189
## 359 359 Arctic Monkeys 5569806731
ggplot(data = most_streamed_artist, aes(x = streams.streams, y = reorder(streams.artist_name, streams.streams))) +
geom_bar(stat = "identity", fill = "#29AB87") +
labs(x = "Total streams (Billions)", y = "Artist", title = "Top 10 Most Streamed Artists") +
theme_minimal() +
theme_minimal() +
scale_x_continuous(labels = scales::label_number(scale = 1e-9, suffix = "B"))
Artist with most tracks
Making count of tracks
artist_track_count <- table(spotify$artist_name)
DF of most tracks
most_tracks_artist <- names(which.max(artist_track_count))
num_tracks <- max(artist_track_count)
Printing artist with most tracks
cat("Artist with most tracks is '", most_tracks_artist, "' with '", num_tracks, "' tracks\n")
## Artist with most tracks is ' Taylor Swift ' with ' 36 ' tracks
Sorting track counts in desc order
sorted_artist_track_counts <- sort(artist_track_count, decreasing = TRUE)
Plot of the top 10 artist with most tracks
top_10_artists <- head(sorted_artist_track_counts, 10)
top_10_artists
##
## Taylor Swift The Weeknd Bad Bunny Kendrick Lamar SZA
## 36 34 26 23 23
## Drake Harry Styles Feid Bad Bunny 21 Savage
## 19 17 15 14 13
barplot(top_10_artists,
beside = TRUE,
col = "skyblue",
main = "Top 10 Artists with Most Tracks",
xlab = "Artist",
ylab = "Number of Songs",
names.arg = names(top_10_artists),
cex.names = 0.6,
las = 2)
Calculating Correlation and plotting graph
Changing column names
colnames(spotify)[18] = "danceability"
colnames(spotify)[19] = "valence"
spotify
## # A tibble: 1,479 × 24
## track_name artis…¹ relea…² relea…³ relea…⁴ in_sp…⁵ in_sp…⁶ streams in_ap…⁷
## <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <int> <dbl>
## 1 Take Me To C… "Hozie… 2013 9 13 23804 31 2.14e9 187
## 2 Circles "Post … 2019 8 30 19664 16 2.13e9 391
## 3 Love Yourself "Justi… 2015 11 9 22730 5 2.12e9 289
## 4 All of Me "John … 2013 8 1 27221 0 2.09e9 308
## 5 Counting Sta… "OneRe… 2013 1 1 29215 43 2.01e9 179
## 6 Riptide "Vance… 1975 1 1 31123 55 2.01e9 300
## 7 Wake Me Up -… "Avici… 2013 1 1 50887 34 1.97e9 315
## 8 Can't Hold U… "Ray D… 2011 8 16 6074 52 1.95e9 201
## 9 Can't Hold U… " Ryan… 2011 8 16 6074 52 1.95e9 201
## 10 Can't Hold U… " Mack… 2011 8 16 6074 52 1.95e9 201
## # … with 1,469 more rows, 15 more variables: in_apple_charts <dbl>,
## # in_deezer_playlists <dbl>, in_deezer_charts <dbl>, in_shazam_charts <dbl>,
## # bpm <dbl>, key <chr>, mode <chr>, `danceability_%` <dbl>,
## # danceability <dbl>, valence <dbl>, `acousticness_%` <dbl>,
## # `instrumentalness_%` <dbl>, `liveness_%` <dbl>, `speechiness_%` <dbl>,
## # streams_numeric <dbl>, and abbreviated variable names ¹artist_name,
## # ²released_year, ³released_month, ⁴released_day, ⁵in_spotify_playlists, …
# Dropping column
spotify <- spotify[,!names(spotify) %in% c("danceability_%")]
Correlation between Daccebility and Valence
correlation_coefficient <- cor(spotify$valence, spotify$danceability)
correlation_coefficient
## [1] 0.3307313
Scatterplot of Correlation between Daccebility and Valence
ggplot(spotify, aes(x = valence, y = danceability)) +
geom_point(alpha = 0.5) +
labs(x = "Valence (%)", y = "Danceability (%)", title = "Scatter Plot: Danceability vs. Valence") +
theme_minimal() +
theme(panel.grid = element_blank())
Scatterplot of Correlation between Daccebility and Valence with regression line
ggplot(spotify, aes(x = valence, y = danceability)) +
geom_point(alpha = 0.5) +
geom_smooth(method = "lm", se = FALSE, color = "blue") +
labs(x = "Valence (%)", y = "Danceability (%)", title = "Regression Line: Danceability vs. Valence") +
theme_minimal() +
theme(panel.grid = element_blank())
## `geom_smooth()` using formula = 'y ~ x'
Correlation between Acousticness and Danceability
colnames(spotify)[19] = "acoustic"
spotify
## # A tibble: 1,479 × 23
## track_name artis…¹ relea…² relea…³ relea…⁴ in_sp…⁵ in_sp…⁶ streams in_ap…⁷
## <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <int> <dbl>
## 1 Take Me To C… "Hozie… 2013 9 13 23804 31 2.14e9 187
## 2 Circles "Post … 2019 8 30 19664 16 2.13e9 391
## 3 Love Yourself "Justi… 2015 11 9 22730 5 2.12e9 289
## 4 All of Me "John … 2013 8 1 27221 0 2.09e9 308
## 5 Counting Sta… "OneRe… 2013 1 1 29215 43 2.01e9 179
## 6 Riptide "Vance… 1975 1 1 31123 55 2.01e9 300
## 7 Wake Me Up -… "Avici… 2013 1 1 50887 34 1.97e9 315
## 8 Can't Hold U… "Ray D… 2011 8 16 6074 52 1.95e9 201
## 9 Can't Hold U… " Ryan… 2011 8 16 6074 52 1.95e9 201
## 10 Can't Hold U… " Mack… 2011 8 16 6074 52 1.95e9 201
## # … with 1,469 more rows, 14 more variables: in_apple_charts <dbl>,
## # in_deezer_playlists <dbl>, in_deezer_charts <dbl>, in_shazam_charts <dbl>,
## # bpm <dbl>, key <chr>, mode <chr>, danceability <dbl>, valence <dbl>,
## # acoustic <dbl>, `instrumentalness_%` <dbl>, `liveness_%` <dbl>,
## # `speechiness_%` <dbl>, streams_numeric <dbl>, and abbreviated variable
## # names ¹artist_name, ²released_year, ³released_month, ⁴released_day,
## # ⁵in_spotify_playlists, ⁶in_spotify_charts, ⁷in_apple_playlists
correlation_coefficient_for_acous <- cor(spotify$acoustic, spotify$danceability)
correlation_coefficient_for_acous
## [1] -0.04346136
Scatterplot of Correlation between Acousticness and Danceability
ggplot(spotify, aes(x = acoustic, y = danceability)) +
geom_point(alpha = 0.5) +
labs(x = "Acousticness (%)", y = "Danceability (%)", title = "Scatter Plot: Danceability vs. Acousticness") +
theme_minimal() +
theme(panel.grid = element_blank())
Scatterplot of Correlation between Acousticness and Danceability with regression line
ggplot(spotify, aes(x = acoustic, y = danceability)) +
geom_point(alpha = 0.5) +
geom_smooth(method = "lm", se = FALSE, color = "red")
## `geom_smooth()` using formula = 'y ~ x'
labs(x = "Acousticness (%)", y = "Danceability (%)", title = "Scatter Plot: Danceability vs. Acousticness") +
theme_minimal() +
theme(panel.grid = element_blank())
## NULL
Correlation between Song popularity due to valence
valence_correlation <- cor(spotify$valence, spotify$streams)
valence_correlation
## [1] NA
Scatterplot of correlation between song popularity due to valence
ggplot(spotify, aes(x = valence, y = streams)) +
geom_point(color = "blue", alpha = 0.7, shape = 15) +
labs(x = "Valence (%)", y = "Streams (billions)", title = "Valence vs. Song Popularity")+
scale_y_continuous(labels = scales::label_number(scale = 1e-9, suffix = "B"))
## Warning: Removed 35 rows containing missing values (`geom_point()`).
theme_minimal()
## List of 94
## $ line :List of 6
## ..$ colour : chr "black"
## ..$ linewidth : num 0.5
## ..$ linetype : num 1
## ..$ lineend : chr "butt"
## ..$ arrow : logi FALSE
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_line" "element"
## $ rect :List of 5
## ..$ fill : chr "white"
## ..$ colour : chr "black"
## ..$ linewidth : num 0.5
## ..$ linetype : num 1
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_rect" "element"
## $ text :List of 11
## ..$ family : chr ""
## ..$ face : chr "plain"
## ..$ colour : chr "black"
## ..$ size : num 11
## ..$ hjust : num 0.5
## ..$ vjust : num 0.5
## ..$ angle : num 0
## ..$ lineheight : num 0.9
## ..$ margin : 'margin' num [1:4] 0points 0points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : logi FALSE
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ title : NULL
## $ aspect.ratio : NULL
## $ axis.title : NULL
## $ axis.title.x :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 1
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 2.75points 0points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.title.x.top :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 0
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 2.75points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.title.x.bottom : NULL
## $ axis.title.y :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 1
## ..$ angle : num 90
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 2.75points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.title.y.left : NULL
## $ axis.title.y.right :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 0
## ..$ angle : num -90
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 0points 2.75points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.text :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : chr "grey30"
## ..$ size : 'rel' num 0.8
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.text.x :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 1
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 2.2points 0points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.text.x.top :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 0
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 2.2points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.text.x.bottom : NULL
## $ axis.text.y :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : num 1
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 2.2points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.text.y.left : NULL
## $ axis.text.y.right :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : num 0
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 0points 2.2points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.ticks : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ axis.ticks.x : NULL
## $ axis.ticks.x.top : NULL
## $ axis.ticks.x.bottom : NULL
## $ axis.ticks.y : NULL
## $ axis.ticks.y.left : NULL
## $ axis.ticks.y.right : NULL
## $ axis.ticks.length : 'simpleUnit' num 2.75points
## ..- attr(*, "unit")= int 8
## $ axis.ticks.length.x : NULL
## $ axis.ticks.length.x.top : NULL
## $ axis.ticks.length.x.bottom: NULL
## $ axis.ticks.length.y : NULL
## $ axis.ticks.length.y.left : NULL
## $ axis.ticks.length.y.right : NULL
## $ axis.line : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ axis.line.x : NULL
## $ axis.line.x.top : NULL
## $ axis.line.x.bottom : NULL
## $ axis.line.y : NULL
## $ axis.line.y.left : NULL
## $ axis.line.y.right : NULL
## $ legend.background : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ legend.margin : 'margin' num [1:4] 5.5points 5.5points 5.5points 5.5points
## ..- attr(*, "unit")= int 8
## $ legend.spacing : 'simpleUnit' num 11points
## ..- attr(*, "unit")= int 8
## $ legend.spacing.x : NULL
## $ legend.spacing.y : NULL
## $ legend.key : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ legend.key.size : 'simpleUnit' num 1.2lines
## ..- attr(*, "unit")= int 3
## $ legend.key.height : NULL
## $ legend.key.width : NULL
## $ legend.text :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : 'rel' num 0.8
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ legend.text.align : NULL
## $ legend.title :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : num 0
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ legend.title.align : NULL
## $ legend.position : chr "right"
## $ legend.direction : NULL
## $ legend.justification : chr "center"
## $ legend.box : NULL
## $ legend.box.just : NULL
## $ legend.box.margin : 'margin' num [1:4] 0cm 0cm 0cm 0cm
## ..- attr(*, "unit")= int 1
## $ legend.box.background : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ legend.box.spacing : 'simpleUnit' num 11points
## ..- attr(*, "unit")= int 8
## $ panel.background : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ panel.border : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ panel.spacing : 'simpleUnit' num 5.5points
## ..- attr(*, "unit")= int 8
## $ panel.spacing.x : NULL
## $ panel.spacing.y : NULL
## $ panel.grid :List of 6
## ..$ colour : chr "grey92"
## ..$ linewidth : NULL
## ..$ linetype : NULL
## ..$ lineend : NULL
## ..$ arrow : logi FALSE
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_line" "element"
## $ panel.grid.major : NULL
## $ panel.grid.minor :List of 6
## ..$ colour : NULL
## ..$ linewidth : 'rel' num 0.5
## ..$ linetype : NULL
## ..$ lineend : NULL
## ..$ arrow : logi FALSE
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_line" "element"
## $ panel.grid.major.x : NULL
## $ panel.grid.major.y : NULL
## $ panel.grid.minor.x : NULL
## $ panel.grid.minor.y : NULL
## $ panel.ontop : logi FALSE
## $ plot.background : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ plot.title :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : 'rel' num 1.2
## ..$ hjust : num 0
## ..$ vjust : num 1
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 5.5points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ plot.title.position : chr "panel"
## $ plot.subtitle :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : num 0
## ..$ vjust : num 1
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 5.5points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ plot.caption :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : 'rel' num 0.8
## ..$ hjust : num 1
## ..$ vjust : num 1
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 5.5points 0points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ plot.caption.position : chr "panel"
## $ plot.tag :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : 'rel' num 1.2
## ..$ hjust : num 0.5
## ..$ vjust : num 0.5
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ plot.tag.position : chr "topleft"
## $ plot.margin : 'margin' num [1:4] 5.5points 5.5points 5.5points 5.5points
## ..- attr(*, "unit")= int 8
## $ strip.background : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ strip.background.x : NULL
## $ strip.background.y : NULL
## $ strip.clip : chr "inherit"
## $ strip.placement : chr "inside"
## $ strip.text :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : chr "grey10"
## ..$ size : 'rel' num 0.8
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 4.4points 4.4points 4.4points 4.4points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ strip.text.x : NULL
## $ strip.text.y :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : num -90
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ strip.switch.pad.grid : 'simpleUnit' num 2.75points
## ..- attr(*, "unit")= int 8
## $ strip.switch.pad.wrap : 'simpleUnit' num 2.75points
## ..- attr(*, "unit")= int 8
## $ strip.text.y.left :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : num 90
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## - attr(*, "class")= chr [1:2] "theme" "gg"
## - attr(*, "complete")= logi TRUE
## - attr(*, "validate")= logi TRUE
Scatterplot of correlation between song popularity due to valence with regression line
ggplot(spotify, aes(x = valence, y = streams)) +
geom_point(color = "blue", alpha = 0.7, shape = 15) +
geom_smooth(method = "lm", se = FALSE, color = "green")
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 35 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 35 rows containing missing values (`geom_point()`).
labs(x = "Valence (%)", y = "Streams (billions)", title = "Valence vs. Song Popularity") +
scale_y_continuous(labels = scales::label_number(scale = 1e-9, suffix = "B"))
## NULL
theme_minimal()
## List of 94
## $ line :List of 6
## ..$ colour : chr "black"
## ..$ linewidth : num 0.5
## ..$ linetype : num 1
## ..$ lineend : chr "butt"
## ..$ arrow : logi FALSE
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_line" "element"
## $ rect :List of 5
## ..$ fill : chr "white"
## ..$ colour : chr "black"
## ..$ linewidth : num 0.5
## ..$ linetype : num 1
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_rect" "element"
## $ text :List of 11
## ..$ family : chr ""
## ..$ face : chr "plain"
## ..$ colour : chr "black"
## ..$ size : num 11
## ..$ hjust : num 0.5
## ..$ vjust : num 0.5
## ..$ angle : num 0
## ..$ lineheight : num 0.9
## ..$ margin : 'margin' num [1:4] 0points 0points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : logi FALSE
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ title : NULL
## $ aspect.ratio : NULL
## $ axis.title : NULL
## $ axis.title.x :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 1
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 2.75points 0points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.title.x.top :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 0
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 2.75points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.title.x.bottom : NULL
## $ axis.title.y :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 1
## ..$ angle : num 90
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 2.75points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.title.y.left : NULL
## $ axis.title.y.right :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 0
## ..$ angle : num -90
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 0points 2.75points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.text :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : chr "grey30"
## ..$ size : 'rel' num 0.8
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.text.x :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 1
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 2.2points 0points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.text.x.top :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 0
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 2.2points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.text.x.bottom : NULL
## $ axis.text.y :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : num 1
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 2.2points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.text.y.left : NULL
## $ axis.text.y.right :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : num 0
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 0points 2.2points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.ticks : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ axis.ticks.x : NULL
## $ axis.ticks.x.top : NULL
## $ axis.ticks.x.bottom : NULL
## $ axis.ticks.y : NULL
## $ axis.ticks.y.left : NULL
## $ axis.ticks.y.right : NULL
## $ axis.ticks.length : 'simpleUnit' num 2.75points
## ..- attr(*, "unit")= int 8
## $ axis.ticks.length.x : NULL
## $ axis.ticks.length.x.top : NULL
## $ axis.ticks.length.x.bottom: NULL
## $ axis.ticks.length.y : NULL
## $ axis.ticks.length.y.left : NULL
## $ axis.ticks.length.y.right : NULL
## $ axis.line : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ axis.line.x : NULL
## $ axis.line.x.top : NULL
## $ axis.line.x.bottom : NULL
## $ axis.line.y : NULL
## $ axis.line.y.left : NULL
## $ axis.line.y.right : NULL
## $ legend.background : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ legend.margin : 'margin' num [1:4] 5.5points 5.5points 5.5points 5.5points
## ..- attr(*, "unit")= int 8
## $ legend.spacing : 'simpleUnit' num 11points
## ..- attr(*, "unit")= int 8
## $ legend.spacing.x : NULL
## $ legend.spacing.y : NULL
## $ legend.key : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ legend.key.size : 'simpleUnit' num 1.2lines
## ..- attr(*, "unit")= int 3
## $ legend.key.height : NULL
## $ legend.key.width : NULL
## $ legend.text :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : 'rel' num 0.8
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ legend.text.align : NULL
## $ legend.title :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : num 0
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ legend.title.align : NULL
## $ legend.position : chr "right"
## $ legend.direction : NULL
## $ legend.justification : chr "center"
## $ legend.box : NULL
## $ legend.box.just : NULL
## $ legend.box.margin : 'margin' num [1:4] 0cm 0cm 0cm 0cm
## ..- attr(*, "unit")= int 1
## $ legend.box.background : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ legend.box.spacing : 'simpleUnit' num 11points
## ..- attr(*, "unit")= int 8
## $ panel.background : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ panel.border : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ panel.spacing : 'simpleUnit' num 5.5points
## ..- attr(*, "unit")= int 8
## $ panel.spacing.x : NULL
## $ panel.spacing.y : NULL
## $ panel.grid :List of 6
## ..$ colour : chr "grey92"
## ..$ linewidth : NULL
## ..$ linetype : NULL
## ..$ lineend : NULL
## ..$ arrow : logi FALSE
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_line" "element"
## $ panel.grid.major : NULL
## $ panel.grid.minor :List of 6
## ..$ colour : NULL
## ..$ linewidth : 'rel' num 0.5
## ..$ linetype : NULL
## ..$ lineend : NULL
## ..$ arrow : logi FALSE
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_line" "element"
## $ panel.grid.major.x : NULL
## $ panel.grid.major.y : NULL
## $ panel.grid.minor.x : NULL
## $ panel.grid.minor.y : NULL
## $ panel.ontop : logi FALSE
## $ plot.background : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ plot.title :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : 'rel' num 1.2
## ..$ hjust : num 0
## ..$ vjust : num 1
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 5.5points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ plot.title.position : chr "panel"
## $ plot.subtitle :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : num 0
## ..$ vjust : num 1
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 5.5points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ plot.caption :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : 'rel' num 0.8
## ..$ hjust : num 1
## ..$ vjust : num 1
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 5.5points 0points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ plot.caption.position : chr "panel"
## $ plot.tag :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : 'rel' num 1.2
## ..$ hjust : num 0.5
## ..$ vjust : num 0.5
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ plot.tag.position : chr "topleft"
## $ plot.margin : 'margin' num [1:4] 5.5points 5.5points 5.5points 5.5points
## ..- attr(*, "unit")= int 8
## $ strip.background : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ strip.background.x : NULL
## $ strip.background.y : NULL
## $ strip.clip : chr "inherit"
## $ strip.placement : chr "inside"
## $ strip.text :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : chr "grey10"
## ..$ size : 'rel' num 0.8
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 4.4points 4.4points 4.4points 4.4points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ strip.text.x : NULL
## $ strip.text.y :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : num -90
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ strip.switch.pad.grid : 'simpleUnit' num 2.75points
## ..- attr(*, "unit")= int 8
## $ strip.switch.pad.wrap : 'simpleUnit' num 2.75points
## ..- attr(*, "unit")= int 8
## $ strip.text.y.left :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : num 90
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## - attr(*, "class")= chr [1:2] "theme" "gg"
## - attr(*, "complete")= logi TRUE
## - attr(*, "validate")= logi TRUE