Data-Informed Thinking + Doing

Data Visualization With Grammar of Graphics

Visualizing TikTok data—using ggplot2 for R, plotnine for Python, and Gadfly for Julia.

Data visualization allows us to communicate complex information and patterns in a visual and intuitive way. It enhances understanding, reveals insights, and helps in identifying trends, outliers, and relationships. Visualizations aid in decision-making, storytelling, and conveying information effectively to a wider audience.

In advancing this art and science, Leland Wilkinson pioneered the Grammar of Graphics, which laid the foundation for a systematic and principled approach to data visualization. It introduced the concept of mapping data to visual aesthetics and provided a grammar-based framework for constructing visualizations. Hadley Wickham’s implementation of Grammar of Graphics (ggplot2 for R), built upon Wilkinson’s ideas and revolutionized data visualization by providing a powerful, flexible, and user-friendly toolset for creating sophisticated and customizable plots. Together, Wilkinson’s work and Wickham’s implementation have significantly advanced the field of data visualization, enabling data analysts/scientists to create insightful and impactful visual representations of their data.

Let’s see ggplot2 for R—as well as the ggplot2 “forks” for Python (plotnine) and Julia (Gadfly)—in action.

Getting Started

If you are interested in reproducing this work, here are the versions of R, Python, and Julia used (as well as the respective packages for each). Additionally, my coding style here is verbose, in order to trace back where functions/methods and variables are originating from, and make this a learning experience for everyone—including me.

cat(R.version$version.string, R.version$nickname)
R version 4.2.3 (2023-03-15) Shortstop Beagle
require(devtools)
devtools::install_version("readxl", version="1.4.3", repos="http://cran.us.r-project.org")
devtools::install_version("tibble", version="3.2.1", repos="http://cran.us.r-project.org")
devtools::install_version("dplyr", version="1.1.2", repos="http://cran.us.r-project.org")
devtools::install_version("scales", version="1.2.1", repos="http://cran.us.r-project.org")
devtools::install_version("ggplot2", version="3.4.2", repos="http://cran.us.r-project.org")
devtools::install_github("wilkelab/ggridges", dependencies=FALSE)
devtools::install_github("ricardo-bion/ggradar", dependencies=FALSE)
library(readxl)
library(tibble)
library(dplyr)
library(scales)
library(ggplot2)
library(ggridges)
library(ggradar)
import sys
print(sys.version)
3.11.4 (v3.11.4:d2340ef257, Jun  6 2023, 19:15:51) [Clang 13.0.0 (clang-1300.0.29.30)]
!pip install pandas==2.0.3
!pip install plotnine==0.12.1
import pandas
import plotnine
using InteractiveUtils
InteractiveUtils.versioninfo()
Julia Version 1.9.2
Commit e4ee485e909 (2023-07-05 09:39 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin22.4.0)
  CPU: 8 × Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, skylake)
  Threads: 1 on 8 virtual cores
Environment:
  DYLD_FALLBACK_LIBRARY_PATH = /Library/Frameworks/R.framework/Resources/lib:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/server
using Pkg
Pkg.add(name="CSV", version="0.10.11")
Pkg.add(name="DataFrames", version="1.5.0")
Pkg.add(name="CategoricalArrays", version="0.10.8")
Pkg.add(name="Colors", version="0.12.10")
Pkg.add(name="Cairo", version="1.0.5")
Pkg.add(name="Gadfly", version="1.3.4")
using Dates
using CSV
using DataFrames
using CategoricalArrays
using Colors
using Cairo
using Gadfly

Importing and Examining Dataset

Upon importing and examining the dataset, we can see that the songs data frame dimension is 223 rows and 18 columns, while the hashtags data frame dimension is 1200 rows and 52 columns.

# https://www.kaggle.com/datasets/sveta151/tiktok-popular-songs-2019
tiktok_songs_r <- read.csv("../../dataset/tiktok-songs-2019.csv", stringsAsFactors=TRUE)
utils::str(object=tiktok_songs_r)
'data.frame':	223 obs. of  18 variables:
 $ track_name      : Factor w/ 221 levels "223's (feat. 9lokknine)",..: 161 39 14 181 158 59 163 60 141 72 ...
 $ artist_name     : Factor w/ 209 levels "24kGoldn","88rising",..: 128 153 32 29 129 139 19 167 14 61 ...
 $ artist_pop      : int  53 61 57 60 58 57 53 65 43 70 ...
 $ album           : Factor w/ 220 levels "#3 Deluxe Version",..: 117 146 26 177 9 52 19 53 129 174 ...
 $ track_pop       : int  68 53 69 2 0 1 0 0 58 64 ...
 $ danceability    : num  0.618 0.744 0.829 0.847 0.738 0.516 0.649 0.877 0.736 0.474 ...
 $ energy          : num  0.955 0.845 0.792 0.678 0.983 0.358 0.716 0.503 0.81 0.948 ...
 $ loudness        : num  -3.84 -7.42 -3.75 -8.63 -4.37 ...
 $ mode            : int  1 0 0 1 0 0 1 0 1 1 ...
 $ key             : int  4 4 2 9 5 8 11 7 5 3 ...
 $ speechiness     : num  0.0798 0.253 0.0668 0.109 0.0855 0.424 0.0445 0.22 0.0906 0.122 ...
 $ acousticness    : num  0.00221 0.759 0.726 0.0669 0.038 0.743 0.0879 0.164 0.077 0.0223 ...
 $ instrumentalness: num  0.00000309 0.232 0.00000583 0 0.00000593 0.0000013 0.03 0.0132 0 0 ...
 $ liveness        : num  0.486 0.1 0.122 0.274 0.183 0.0813 0.0824 0.102 0.0523 0.43 ...
 $ valence         : num  0.79 0.749 0.758 0.811 0.957 0.397 0.503 0.529 0.387 0.611 ...
 $ tempo           : num  150 75.2 118 98 93 ...
 $ time_signature  : int  4 4 4 4 4 4 4 4 4 4 ...
 $ duration_ms     : int  179947 160000 215507 200594 235760 124000 235813 144000 154448 195373 ...
utils::head(x=tiktok_songs_r, n=8)
            track_name                artist_name artist_pop                album track_pop danceability energy loudness mode key speechiness acousticness instrumentalness liveness valence tempo time_signature duration_ms
1             Shake It              Metro Station         53        Metro Station        68         0.62   0.95     -3.8    1   4       0.080       0.0022        0.0000031    0.486    0.79   150              4      179947
2     Chinese New Year                      SALES         61           SALES - EP        53         0.74   0.84     -7.4    0   4       0.253       0.7590        0.2320000    0.100    0.75    75              4      160000
3       Baby I'm Yours                   Breakbot         57         By Your Side        69         0.83   0.79     -3.8    0   2       0.067       0.7260        0.0000058    0.122    0.76   118              4      215507
4           The Git Up               Blanco Brown         60           The Git Up         2         0.85   0.68     -8.6    1   9       0.109       0.0669        0.0000000    0.274    0.81    98              4      200594
5 Say Hey (I Love You) Michael Franti & Spearhead         58    All Rebel Rockers         0         0.74   0.98     -4.4    0   5       0.086       0.0380        0.0000059    0.183    0.96    93              4      235760
6        Falling for U                    Peachy!         57        Falling for U         1         0.52   0.36    -12.0    0   8       0.424       0.7430        0.0000013    0.081    0.40    80              4      124000
7       Shooting Stars                Bag Raiders         53 Bag Raiders (Deluxe)         0         0.65   0.72     -6.2    1  11       0.044       0.0879        0.0300000    0.082    0.50   125              4      235813
8                 fast                      Sueco         65                 fast         0         0.88   0.50    -10.3    0   7       0.220       0.1640        0.0132000    0.102    0.53   100              4      144000
which(is.na(tiktok_songs_r))
integer(0)
# https://www.kaggle.com/datasets/anasmahmood000/tiktok-dataset
tiktok_hashtags_r <- readxl::read_excel("../../dataset/tiktok-hashtags.xlsx")
utils::str(object=tiktok_hashtags_r)
tibble [1,200 × 52] (S3: tbl_df/tbl/data.frame)
 $ authorMeta/avatar                     : chr [1:1200] "https://p16-sign-sg.tiktokcdn.com/aweme/720x720/tos-alisg-avt-0068/3d7f8d376e2ae1e5bf2d5d34ce4227cf.jpeg?x-expi"| __truncated__ "https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/481098764045c3ce40803bbb7a4ce8f5~c5_720x720.jpeg?x-expire"| __truncated__ "https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/25e7644ef6de2fda3ceb6b3ded7ec1e6~c5_720x720.jpeg?x-expire"| __truncated__ "https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/1fb842873d85dbffa71c9787e577cb52~c5_720x720.jpeg?x-expire"| __truncated__ ...
 $ authorMeta/digg                       : num [1:1200] 420 10800 251 218 47600 ...
 $ authorMeta/fans                       : num [1:1200] 13200000 1300000 696800 510200 3300000 ...
 $ authorMeta/following                  : num [1:1200] 28 182 42 56 690 ...
 $ authorMeta/heart                      : num [1:1200] 150400000 35100000 15900000 32100000 137300000 ...
 $ authorMeta/id                         : chr [1:1200] "6713126981665686530" "6929583089811522566" "7083448802635596842" "7087287470497645573" ...
 $ authorMeta/name                       : chr [1:1200] "miso_ara" "crinka11" "iampets_com" "dailydosevideos_" ...
 $ authorMeta/nickName                   : chr [1:1200] "미소아라 Miso_Ara" "Chris Rinker" "IamPéts" "dailydosevideos" ...
 $ authorMeta/signature                  : chr [1:1200] "soonent@soon-ent.co.kr\r\n.\r\n Miso Ara IG" "insta: chrisrinker73" "Pet supplies, toys online store. All products in our video can buy in below link" "Daily dose of videos/memes \r\nsupport the page if you want ❤" ...
 $ authorMeta/verified                   : chr [1:1200] "true" "false" "false" "false" ...
 $ authorMeta/video                      : num [1:1200] 303 518 90 84 247 ...
 $ commentCount                          : num [1:1200] 66000 154100 55300 70600 35500 ...
 $ createTime                            : num [1:1200] 1582632666 1620176163 1649340306 1652274907 1586829887 ...
 $ createTimeISO                         : chr [1:1200] "2020-02-25T12:11:06.000Z" "2021-05-05T00:56:03.000Z" "2022-04-07T14:05:06.000Z" "2022-05-11T13:15:07.000Z" ...
 $ diggCount                             : num [1:1200] 19300000 15400000 13900000 13100000 13100000 12800000 12500000 12100000 11600000 11300000 ...
 $ downloaded                            : chr [1:1200] "false" "false" "false" "false" ...
 $ effectStickers/0/ID                   : chr [1:1200] NA NA NA NA ...
 $ effectStickers/0/name                 : chr [1:1200] NA NA NA NA ...
 $ effectStickers/0/stickerStats/useCount: num [1:1200] NA NA NA NA NA NA NA NA NA NA ...
 $ effectStickers/1/ID                   : chr [1:1200] NA NA NA NA ...
 $ effectStickers/1/name                 : chr [1:1200] NA NA NA NA ...
 $ effectStickers/1/stickerStats/useCount: num [1:1200] NA NA NA NA NA NA NA NA NA NA ...
 $ hashtags/0/cover                      : chr [1:1200] "https://p16-amd-va.tiktokcdn.com/obj/musically-maliva-obj/1e6b1debcaef7ccdb2ad6107feb180b8" NA NA "https://p16-amd-va.tiktokcdn.com/obj/musically-maliva-obj/c9361f827e1dcb19d2e54e58654c9f55.jpeg" ...
 $ hashtags/0/id                         : chr [1:1200] "20408" "229207" "5424" "23864" ...
 $ hashtags/0/name                       : chr [1:1200] "woah" "fyp" "funny" "meme" ...
 $ hashtags/0/title                      : chr [1:1200] "Wait... one second... okay, WOAH!" NA "What's so #Funny?" NA ...
 $ hashtags/1/cover                      : chr [1:1200] "https://p16-sg.tiktokcdn.com/obj/tiktok-obj/1641017550056449.PNG" "https://p16-amd-va.tiktokcdn.com/obj/musically-maliva-obj/c9361f827e1dcb19d2e54e58654c9f55.jpeg" NA NA ...
 $ hashtags/1/id                         : chr [1:1200] "3780738" "23864" "107738" "7032147077300682757" ...
 $ hashtags/1/name                       : chr [1:1200] "woahchallenge" "meme" "funnyvideos" "trynottolaughtiktoktv" ...
 $ hashtags/1/title                      : chr [1:1200] "Woah woah woah, stop right there!  Have you done the latest dance challange yet!  Dab, floss, or just show off "| __truncated__ NA NA "TikTok's Funniest Home Videos!" ...
 $ id                                    : chr [1:1200] "6797294685082619137" "6958603581675031814" "7083862667613490474" "7096466682046188805" ...
 $ mediaUrls/0                           : chr [1:1200] "https://v16-webapp.tiktok.com/c5e1c65e3846e6fe306f3bee52c825e4/62e2021c/video/n/v0102/e99ec24738854b7985d2926c1"| __truncated__ "https://v16-webapp.tiktok.com/fcc73bd189606c1de0970ba0a9307e3d/62e20215/video/tos/useast2a/tos-useast2a-ve-0068"| __truncated__ "https://v16-webapp.tiktok.com/6fdb8074e5ec9438b97d77db00ed7296/62e20223/video/tos/maliva/tos-maliva-ve-0068c799"| __truncated__ "https://v16-webapp.tiktok.com/7cd241572bcadf38463d6c07c543d181/62e20248/video/tos/useast2a/tos-useast2a-ve-0068"| __truncated__ ...
 $ mentions/0                            : chr [1:1200] NA NA NA NA ...
 $ mentions/1                            : chr [1:1200] NA NA NA NA ...
 $ mentions/2                            : chr [1:1200] NA NA NA NA ...
 $ mentions/3                            : chr [1:1200] NA NA NA NA ...
 $ mentions/4                            : chr [1:1200] NA NA NA NA ...
 $ mentions/5                            : chr [1:1200] NA NA NA NA ...
 $ musicMeta/musicAlbum                  : chr [1:1200] NA NA NA NA ...
 $ musicMeta/musicAuthor                 : chr [1:1200] "미소아라 Miso_Ara" "Chris Rinker" "IamPéts" "dailydosevideos" ...
 $ musicMeta/musicName                   : chr [1:1200] "오리지널 사운드 - Miso_Ara" "original sound" "nhạc nền" "original sound" ...
 $ musicMeta/musicOriginal               : chr [1:1200] "true" "true" "true" "true" ...
 $ musicMeta/playUrl                     : chr [1:1200] "https://sf16-ies-music-sg.tiktokcdn.com/obj/tiktok-obj/1659493776138258.mp3" "https://sf16-ies-music-va.tiktokcdn.com/obj/musically-maliva-obj/6958603596321655557.mp3" "https://sf16-ies-music-va.tiktokcdn.com/obj/ies-music-ttp-dup-us/7083862650291211054.mp3" "https://sf16-ies-music-va.tiktokcdn.com/obj/musically-maliva-obj/7096789979888372485.mp3" ...
 $ playCount                             : num [1:1200] 200600000 79600000 106100000 72500000 62700000 ...
 $ searchHashtag/name                    : chr [1:1200] "meme" "meme" "meme" "meme" ...
 $ searchHashtag/views                   : chr [1:1200] "556B" "556B" "556B" "556B" ...
 $ shareCount                            : num [1:1200] 377700 205400 323000 133400 252900 ...
 $ text                                  : chr [1:1200] "Ara Woah  #woah  #woahchallenge  #foryou  #fyp  #meme  #이아라  #틱톡  #tiktok" "#fyp #meme #funny #meme #vine" "The end #funny #funnyvideos #animals #haha #meme #dog #cat #fypage #viral #pets" "Try not to laugh  hard #meme #trynottolaughtiktoktv" ...
 $ videoMeta/duration                    : num [1:1200] 17 11 25 62 36 10 18 16 13 19 ...
 $ videoMeta/height                      : num [1:1200] 1280 1024 1024 1024 1024 ...
 $ videoMeta/width                       : num [1:1200] 720 576 576 576 576 540 720 576 540 576 ...
 $ webVideoUrl                           : chr [1:1200] "https://www.tiktok.com/@miso_ara/video/6797294685082619137" "https://www.tiktok.com/@crinka11/video/6958603581675031814" "https://www.tiktok.com/@iampets_com/video/7083862667613490474" "https://www.tiktok.com/@dailydosevideos_/video/7096466682046188805" ...
utils::head(x=tiktok_hashtags_r, n=8)
# A tibble: 8 × 52
  `authorMeta/avatar`                                                                                                                                                            `authorMeta/digg` `authorMeta/fans` `authorMeta/following` `authorMeta/heart` `authorMeta/id`     `authorMeta/name` `authorMeta/nickName` `authorMeta/signature`                                                             `authorMeta/verified` `authorMeta/video` commentCount createTime createTimeISO            diggCount downloaded `effectStickers/0/ID` `effectStickers/0/name` `effectStickers/0/stickerStats/useCount` `effectStickers/1/ID` `effectStickers/1/name` `effectStickers/1/stickerStats/useCount` `hashtags/0/cover`                                                                              `hashtags/0/id` `hashtags/0/name` `hashtags/0/title`                                                                                                                                                     `hashtags/1/cover`                                                                              `hashtags/1/id`     `hashtags/1/name`     `hashtags/1/title`                                                                                                                                 id                  `mediaUrls/0`                                                                                                                                                                                                                                                                                                                                                                                                                                                  `mentions/0` `mentions/1` `mentions/2` `mentions/3` `mentions/4` `mentions/5` `musicMeta/musicAlbum` `musicMeta/musicAuthor` `musicMeta/musicName`      `musicMeta/musicOriginal` `musicMeta/playUrl`                                                                               playCount `searchHashtag/name` `searchHashtag/views` shareCount text                                                                                                                                           `videoMeta/duration` `videoMeta/height` `videoMeta/width` webVideoUrl                                                       
  <chr>                                                                                                                                                                                      <dbl>             <dbl>                  <dbl>              <dbl> <chr>               <chr>             <chr>                 <chr>                                                                              <chr>                              <dbl>        <dbl>      <dbl> <chr>                        <dbl> <chr>      <chr>                 <chr>                                                      <dbl> <chr>                 <chr>                                                      <dbl> <chr>                                                                                           <chr>           <chr>             <chr>                                                                                                                                                                  <chr>                                                                                           <chr>               <chr>                 <chr>                                                                                                                                              <chr>               <chr>                                                                                                                                                                                                                                                                                                                                                                                                                                                          <chr>        <chr>        <chr>        <chr>        <chr>        <chr>        <chr>                  <chr>                   <chr>                      <chr>                     <chr>                                                                                                 <dbl> <chr>                <chr>                      <dbl> <chr>                                                                                                                                                         <dbl>              <dbl>             <dbl> <chr>                                                             
1 https://p16-sign-sg.tiktokcdn.com/aweme/720x720/tos-alisg-avt-0068/3d7f8d376e2ae1e5bf2d5d34ce4227cf.jpeg?x-expires=1659128400&x-signature=fP%2BSSNIqUeMNNLO5Az7FN27SJ1k%3D                   420          13200000                     28          150400000 6713126981665686530 miso_ara          미소아라 Miso_Ara     "soonent@soon-ent.co.kr\r\n.\r\n Miso Ara IG"                                      true                                 303        66000 1582632666 2020-02-25T12:11:06.000Z  19300000 false      <NA>                  <NA>                                                          NA <NA>                  <NA>                                                          NA https://p16-amd-va.tiktokcdn.com/obj/musically-maliva-obj/1e6b1debcaef7ccdb2ad6107feb180b8      20408           woah              "Wait... one second... okay, WOAH!"                                                                                                                                    https://p16-sg.tiktokcdn.com/obj/tiktok-obj/1641017550056449.PNG                                3780738             woahchallenge         Woah woah woah, stop right there!  Have you done the latest dance challange yet!  Dab, floss, or just show off your moves with the #WoahChallenge! 6797294685082619137 https://v16-webapp.tiktok.com/c5e1c65e3846e6fe306f3bee52c825e4/62e2021c/video/n/v0102/e99ec24738854b7985d2926c1410767d/?a=1988&ch=0&cr=0&dr=0&lr=tiktok&cd=0%7C0%7C1%7C0&cv=1&br=1492&bt=746&btag=80000&cs=0&ds=3&ft=gKSYZ8beo0PD1.hipsg9w.FE75LiaQ2D~j8&mime_type=video_mp4&qs=0&rc=NDplM2VlNTY4NDNoPGRkN0BpM286bGxvazZqczMzPDgzM0BgLjIxLy9iXjAxY2EzXmAvYSNvNTFkZm1rcF5fLS00LzRzcw%3D%3D&l=202207272127060102230831572562751B                                 <NA>         <NA>         <NA>         <NA>         <NA>         <NA>         <NA>                   미소아라 Miso_Ara       오리지널 사운드 - Miso_Ara true                      https://sf16-ies-music-sg.tiktokcdn.com/obj/tiktok-obj/1659493776138258.mp3                       200600000 meme                 556B                      377700 Ara Woah  #woah  #woahchallenge  #foryou  #fyp  #meme  #이아라  #틱톡  #tiktok                                                                                   17               1280               720 https://www.tiktok.com/@miso_ara/video/6797294685082619137        
2 https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/481098764045c3ce40803bbb7a4ce8f5~c5_720x720.jpeg?x-expires=1659128400&x-signature=SgmuV2iwipES%2BPUxZ0e%2Bl8xaCRA%3D                 10800           1300000                    182           35100000 6929583089811522566 crinka11          Chris Rinker          "insta: chrisrinker73"                                                             false                                518       154100 1620176163 2021-05-05T00:56:03.000Z  15400000 false      <NA>                  <NA>                                                          NA <NA>                  <NA>                                                          NA <NA>                                                                                            229207          fyp                <NA>                                                                                                                                                                  https://p16-amd-va.tiktokcdn.com/obj/musically-maliva-obj/c9361f827e1dcb19d2e54e58654c9f55.jpeg 23864               meme                  <NA>                                                                                                                                               6958603581675031814 https://v16-webapp.tiktok.com/fcc73bd189606c1de0970ba0a9307e3d/62e20215/video/tos/useast2a/tos-useast2a-ve-0068c002/3e9a31d1340143e1ad520396bf4f585a/?a=1988&ch=0&cr=0&dr=0&lr=tiktok_m&cd=0%7C0%7C1%7C0&cv=1&br=1380&bt=690&btag=80000&cs=0&ds=3&ft=gKSYZ8beo0PD1khipsg9w.FE75LiaQ2D~j8&mime_type=video_mp4&qs=0&rc=OTM0PDxmNDw0OGc7ZDU5M0BpanVpc3U7dTh4NTMzNzczM0A2MGMtMTQtXzIxXi0tMC4zYSNmYzJsM2xebjVgLS1kMTZzcw%3D%3D&l=202207272127060102230831572562751B <NA>         <NA>         <NA>         <NA>         <NA>         <NA>         <NA>                   Chris Rinker            original sound             true                      https://sf16-ies-music-va.tiktokcdn.com/obj/musically-maliva-obj/6958603596321655557.mp3           79600000 meme                 556B                      205400 #fyp #meme #funny #meme #vine                                                                                                                                    11               1024               576 https://www.tiktok.com/@crinka11/video/6958603581675031814        
3 https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/25e7644ef6de2fda3ceb6b3ded7ec1e6~c5_720x720.jpeg?x-expires=1659128400&x-signature=e%2BwijcH%2B%2BQDtDjI%2B1Xi98ORpxkc%3D               251            696800                     42           15900000 7083448802635596842 iampets_com       IamPéts               "Pet supplies, toys online store. All products in our video can buy in below link" false                                 90        55300 1649340306 2022-04-07T14:05:06.000Z  13900000 false      <NA>                  <NA>                                                          NA <NA>                  <NA>                                                          NA <NA>                                                                                            5424            funny             "What's so #Funny?"                                                                                                                                                    <NA>                                                                                            107738              funnyvideos           <NA>                                                                                                                                               7083862667613490474 https://v16-webapp.tiktok.com/6fdb8074e5ec9438b97d77db00ed7296/62e20223/video/tos/maliva/tos-maliva-ve-0068c799-us/805206f34a7b4d8aaa52488af92e6cf7/?a=1988&ch=0&cr=0&dr=0&lr=tiktok_m&cd=0%7C0%7C1%7C0&cv=1&br=2798&bt=1399&btag=80000&cs=0&ds=3&ft=gKSYZ8beo0PD1khipsg9w.FE75LiaQ2D~j8&mime_type=video_mp4&qs=0&rc=ZTxnMzY2PGdkOjQ8ODQzaEBpanUzaGg6ZmloPDMzZzczNEBhXy81MTIzXzYxX2BeMF42YSMyamY1cjRncjRgLS1kMS9zcw%3D%3D&l=202207272127060102230831572562751B <NA>         <NA>         <NA>         <NA>         <NA>         <NA>         <NA>                   IamPéts                 nhạc nền                   true                      https://sf16-ies-music-va.tiktokcdn.com/obj/ies-music-ttp-dup-us/7083862650291211054.mp3          106100000 meme                 556B                      323000 The end #funny #funnyvideos #animals #haha #meme #dog #cat #fypage #viral #pets                                                                                  25               1024               576 https://www.tiktok.com/@iampets_com/video/7083862667613490474     
4 https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/1fb842873d85dbffa71c9787e577cb52~c5_720x720.jpeg?x-expires=1659128400&x-signature=zdwbd9tw%2BTDzHA75lExyguBBioA%3D                     218            510200                     56           32100000 7087287470497645573 dailydosevideos_  dailydosevideos       "Daily dose of videos/memes \r\nsupport the page if you want ❤"                    false                                 84        70600 1652274907 2022-05-11T13:15:07.000Z  13100000 false      <NA>                  <NA>                                                          NA <NA>                  <NA>                                                          NA https://p16-amd-va.tiktokcdn.com/obj/musically-maliva-obj/c9361f827e1dcb19d2e54e58654c9f55.jpeg 23864           meme               <NA>                                                                                                                                                                  <NA>                                                                                            7032147077300682757 trynottolaughtiktoktv TikTok's Funniest Home Videos!                                                                                                                     7096466682046188805 https://v16-webapp.tiktok.com/7cd241572bcadf38463d6c07c543d181/62e20248/video/tos/useast2a/tos-useast2a-ve-0068c001/2bed6611071f43eba329d53b9045862f/?a=1988&ch=0&cr=0&dr=0&lr=tiktok_m&cd=0%7C0%7C1%7C0&cv=1&br=1224&bt=612&btag=80000&cs=0&ds=3&ft=gKSYZ8beo0PD1khipsg9w.FE75LiaQ2D~j8&mime_type=video_mp4&qs=0&rc=Ozc8NmU2ZjU1ZDtlNTxmNUBpM3JkZTk6ZjR1PDMzNzczM0AtMzNhY18zNTMxLmFgLzMxYSM0cHFtcjRnYHFgLS1kMTZzcw%3D%3D&l=202207272127060102230831572562751B <NA>         <NA>         <NA>         <NA>         <NA>         <NA>         <NA>                   dailydosevideos         original sound             true                      https://sf16-ies-music-va.tiktokcdn.com/obj/musically-maliva-obj/7096789979888372485.mp3           72500000 meme                 556B                      133400 Try not to laugh  hard #meme #trynottolaughtiktoktv                                                                                                              62               1024               576 https://www.tiktok.com/@dailydosevideos_/video/7096466682046188805
5 https://p19-sign.tiktokcdn-us.com/tos-useast5-avt-0068-tx/384066bbbd657c12639f9af2112962c7~c5_720x720.jpeg?x-expires=1659128400&x-signature=2fjbTOlibdNwKwKHp7%2B8raRkWxs%3D               47600           3300000                    690          137300000 6621521206107717638 jakeypoov         Jake Sherman          "-.-- --- ..- .-. .     .-.. --- ...- . -..     ---··· -·--·-\r\nIm the vent guy"  true                                 247        35500 1586829887 2020-04-14T02:04:47.000Z  13100000 false      <NA>                  <NA>                                                          NA <NA>                  <NA>                                                          NA <NA>                                                                                            229207          fyp                <NA>                                                                                                                                                                  <NA>                                                                                            1447628             vent                  <NA>                                                                                                                                               6815382456242326789 https://v16-webapp.tiktok.com/89f3c196e4ebdafc5fa78e32cca5bec3/62e2022e/video/tos/useast2a/tos-useast2a-pve-0068/44685dd2b5464044a46418ba8fc8fb34/?a=1988&ch=0&cr=0&dr=0&lr=tiktok_m&cd=0%7C0%7C1%7C0&cv=1&br=1414&bt=707&btag=80000&cs=0&ds=3&ft=gKSYZ8beo0PD1khipsg9w.FE75LiaQ2D~j8&mime_type=video_mp4&qs=0&rc=NDozMzc6ZThoNGY6NzxpZUBpMzg5OTk2aTZrdDMzZDczM0AyYWAuXjBfNjMxMC1eXjIwYSNmZWducmFkaF5fLS0yMTZzcw%3D%3D&l=202207272127060102230831572562751B    @abbysherm   <NA>         <NA>         <NA>         <NA>         <NA>         <NA>                   Jake Sherman            original sound             true                      https://sf16-ies-music-va.tiktokcdn.com/obj/musically-maliva-obj/1663909986295846.mp3              62700000 meme                 556B                      252900 HE DIDN’T HAVE HIS MASK ON  @abbysherm (Follow my insta: JakeyPooV) #fyp #vent #meme #joke                                                                       36               1024               576 https://www.tiktok.com/@jakeypoov/video/6815382456242326789       
6 https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/8a65c3315cb6050b22237ae56c2ae83d~c5_720x720.jpeg?x-expires=1659128400&x-signature=87gqAyFHZkFsBUbmTQWoJN7tz%2Fw%3D                   19000            646700                     86           13000000 6725538523384693765 jiraer23          Jiraer Koullokian     "2nd account : 4k_cars_clips"                                                      false                                127       205200 1613856627 2021-02-20T21:30:27.000Z  12800000 false      1017488               Sugar Crash                                                   NA <NA>                  <NA>                                                          NA <NA>                                                                                            229207          fyp                <NA>                                                                                                                                                                  <NA>                                                                                            42164               foryou                <NA>                                                                                                                                               6931461393459809542 https://v16-webapp.tiktok.com/5777c8f766ae0285c0b04f28d05ebfe9/62e20214/video/tos/useast2a/tos-useast2a-ve-0068c001/14b585d830124655b50381890beb25a1/?a=1988&ch=0&cr=0&dr=0&lr=tiktok_m&cd=0%7C0%7C1%7C0&cv=1&br=1228&bt=614&btag=80000&cs=0&ds=3&ft=gKSYZ8beo0PD1khipsg9w.FE75LiaQ2D~j8&mime_type=video_mp4&qs=0&rc=ZjU3aTZoNGc1NjZoNjs8O0BpanB5b215bnVxMzMzaTczM0AtXzAyMWE0Xi8xYS81MTRgYSNlcWgzZjVxcmxgLS1jMTZzcw%3D%3D&l=202207272127060102230831572562751B <NA>         <NA>         <NA>         <NA>         <NA>         <NA>         SugarCrash!            ElyOtto                 SugarCrash!                false                     https://sf16-ies-music-va.tiktokcdn.com/obj/tos-useast2a-ve-2774/1a6bb53e79284426b463cdc7d10a80d5 100800000 meme                 556B                      795700 DOGS ARE THE BEST . #fyp #foryou #veryfunny #dog #meme #clip                                                                                                     10                960               540 https://www.tiktok.com/@jiraer23/video/6931461393459809542        
7 https://p16-sign-va.tiktokcdn.com/musically-maliva-obj/2490ca8e0e269775f31be844a87c062e~c5_720x720.jpeg?x-expires=1659128400&x-signature=TAW5%2B4BZSJJx5vM3vnBcJ%2B%2FYMsk%3D                230           8000000                     69          313100000 6734403205457642502 samuelgrubbs      Samuel Grubbs         "Emmy Nominee\r\n✞ Romans 10:9-13 ✞\r\nSamuelGrubbsTeam@unitedtalent.com"          true                                 147        59900 1570229474 2019-10-04T22:51:14.000Z  12500000 false      <NA>                  <NA>                                                          NA <NA>                  <NA>                                                          NA https://p16-amd-va.tiktokcdn.com/obj/musically-maliva-obj/a3237c664af342f99d4f97515e4834a5      1745            lol               "Can you laugh any louder?\r\nHow to shoot: \r\n\r\n1. Click the shoot icon. \r\n2. Click on &amp;quot;add sound&amp;quot;\r\n3. Add your meme text. \r\n4. Have fun!" <NA>                                                                                            5424                funny                 What's so #Funny?                                                                                                                                  6744084223445044485 https://v16-webapp.tiktok.com/49d3b2088a432b4bf2b2a65a90fcec73/62e2021c/video/tos/useast2a/tos-useast2a-ve-0068/ed617165988b4b5d995eefb45fd0ab23/?a=1988&ch=0&cr=0&dr=0&lr=tiktok_m&cd=0%7C0%7C1%7C0&cv=1&br=3970&bt=1985&btag=80000&cs=0&ds=3&ft=gKSYZ8beo0PD1khipsg9w.FE75LiaQ2D~j8&mime_type=video_mp4&qs=0&rc=NWZpZzg8ZmQ4aTtoZDQ6OUBpMzhsb3c7NHh2cDMzNTczM0A1YDA2NmIvNmExYTEzX2I2YSNiXjBtZC1oZ19fLS0xMTZzcw%3D%3D&l=202207272127060102230831572562751B    <NA>         <NA>         <NA>         <NA>         <NA>         <NA>         Woah (feat. D3Mstreet) KRYPTO9095              Woah (feat. D3Mstreet)     false                     https://sf16-ies-music-va.tiktokcdn.com/obj/tos-useast2a-ve-2774/8b7574ae7d864d259bc0ee18880505fe 133200000 meme                 556B                      707400 The last guy tho  #lol #funny #foryou #foryoupage #fail #meme #relatable #crazy #wow #haha                                                                       18               1280               720 https://www.tiktok.com/@samuelgrubbs/video/6744084223445044485    
8 https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/525b411cc1b4cf6afe58305bbfed7d74~c5_720x720.jpeg?x-expires=1659128400&x-signature=vB6WejAuBsQBfAWj9NDXQkL5maU%3D                      9929            227000                    208           38100000 6901676902784730118 movienerd74       Movie-Nerd74          "18 love Marvel/DC/StarWars/etc! I post news! \r\nLet’s get that 300k!!!, TY❤️"     false                               3173       113200 1640379934 2021-12-24T21:05:34.000Z  12100000 false      <NA>                  <NA>                                                          NA <NA>                  <NA>                                                          NA <NA>                                                                                            12413           spiderman          <NA>                                                                                                                                                                  <NA>                                                                                            18657157            tobeymaguire          <NA>                                                                                                                                               7045378167200075055 https://v16-webapp.tiktok.com/1287c00b5d2a357cc93c504850e26e85/62e2021a/video/tos/maliva/tos-maliva-ve-0068c799-us/30a8f0ff02424c1f83e811565051aff5/?a=1988&ch=0&cr=0&dr=0&lr=tiktok_m&cd=0%7C0%7C1%7C0&cv=1&br=1460&bt=730&btag=80000&cs=0&ds=3&ft=gKSYZ8beo0PD1khipsg9w.FE75LiaQ2D~j8&mime_type=video_mp4&qs=0&rc=OjU1aGdpaTVpODplOTgzN0BpajVnNTU6Zjo2OjMzZzczNEBeYDMwXy8wXzUxXmIvYV5hYSMzZmQ2cjRvNjBgLS1kMS9zcw%3D%3D&l=202207272127060102230831572562751B  <NA>         <NA>         <NA>         <NA>         <NA>         <NA>         <NA>                   Movie-Nerd74            original sound             true                      https://sf16-ies-music-va.tiktokcdn.com/obj/ies-music-ttp-dup-us/7045378150121032495.mp3           69400000 meme                 556B                      337900 It’s funny how each of them are so different #spiderman #tobeymaguire #andrewgarfield #tomholland #meme #mcu #marveltok #fyp #viral #nowayhome                   16               1024               576 https://www.tiktok.com/@movienerd74/video/7045378167200075055     
utils::tail(x=tiktok_hashtags_r, n=8)
# A tibble: 8 × 52
  `authorMeta/avatar`                                                                                                                                                       `authorMeta/digg` `authorMeta/fans` `authorMeta/following` `authorMeta/heart` `authorMeta/id`     `authorMeta/name`      `authorMeta/nickName` `authorMeta/signature`                                                                `authorMeta/verified` `authorMeta/video` commentCount createTime createTimeISO            diggCount downloaded `effectStickers/0/ID` `effectStickers/0/name` `effectStickers/0/stickerStats/useCount` `effectStickers/1/ID` `effectStickers/1/name` `effectStickers/1/stickerStats/useCount` `hashtags/0/cover` `hashtags/0/id`  `hashtags/0/name` `hashtags/0/title`                                                                                                                                                         `hashtags/1/cover` `hashtags/1/id`  `hashtags/1/name` `hashtags/1/title`                              id                  `mediaUrls/0`                                                                                                                                                                                                                                                                                                                                                                                                                                                   `mentions/0`     `mentions/1`            `mentions/2`  `mentions/3` `mentions/4` `mentions/5` `musicMeta/musicAlbum` `musicMeta/musicAuthor` `musicMeta/musicName` `musicMeta/musicOriginal` `musicMeta/playUrl`                                                                               playCount `searchHashtag/name` `searchHashtag/views` shareCount text                                                                                                                                                 `videoMeta/duration` `videoMeta/height` `videoMeta/width` webVideoUrl                                                             
  <chr>                                                                                                                                                                                 <dbl>             <dbl>                  <dbl>              <dbl> <chr>               <chr>                  <chr>                 <chr>                                                                                 <chr>                              <dbl>        <dbl>      <dbl> <chr>                        <dbl> <chr>      <chr>                 <chr>                                                      <dbl> <chr>                 <chr>                                                      <dbl> <chr>              <chr>            <chr>             <chr>                                                                                                                                                                      <chr>              <chr>            <chr>             <chr>                                           <chr>               <chr>                                                                                                                                                                                                                                                                                                                                                                                                                                                           <chr>            <chr>                   <chr>         <chr>        <chr>        <chr>        <chr>                  <chr>                   <chr>                 <chr>                     <chr>                                                                                                 <dbl> <chr>                <chr>                      <dbl> <chr>                                                                                                                                                               <dbl>              <dbl>             <dbl> <chr>                                                                   
1 https://p16-sign-sg.tiktokcdn.com/aweme/720x720/tos-alisg-avt-0068/4eada0876c5ae48c8ca290ca0ff51c93.jpeg?x-expires=1659128400&x-signature=F2YUnqkFVhd5AdMOM2k57JJNa2U%3D              12900          21400000                     39          641900000 6558418321485414402 cutybeautykhan         Beauty khan           "Hi"                                                                                  true                                2054        17500 1586604332 2020-04-11T11:25:32.000Z   2500000 false      <NA>                  <NA>                                                          NA <NA>                  <NA>                                                          NA <NA>               57511693         tiktokindia       Be the change.musical.ly is now TikTok@indiatiktok #tiktokindia                                                                                                            <NA>               15787069         cutebeuty         <NA>                                            6814413705694940418 https://v16-webapp.tiktok.com/6c07d18af6028f1593df3bda793bc86f/62e205e7/video/tos/useast2a/tos-useast2a-ve-0068c003/48a5335b6b764a35a8b998046205e4af/?a=1988&ch=0&cr=0&dr=0&lr=tiktok_m&cd=0%7C0%7C1%7C0&cv=1&br=4634&bt=2317&btag=80000&cs=0&ds=3&ft=gKSYZ8fuo0PD1lY.psg9wIF2O5LiaQ2D~6a&mime_type=video_mp4&qs=0&rc=OzQ7ZDw7OGU6NTwzOzNmM0BpM2o6bGRtdWp0dDMzaDczM0A2NjJjMmE1XjYxYy1gYGBgYSNuaWs2NS4wZTVfLS1gMTZzcw%3D%3D&l=202207272143190102170192260264CEB8 <NA>             <NA>                    <NA>          <NA>         <NA>         <NA>         <NA>                   azamansari516 Instag    azam                  true                      https://sf16-ies-music-sg.tiktokcdn.com/obj/tiktok-obj/1658121603166241.mp3                        25100000 tiktokdance          17.2B                      23600 #tiktokindia #cutebeuty #tiktokdance                                                                                                                                   15               1024               576 https://www.tiktok.com/@cutybeautykhan/video/6814413705694940418        
2 https://p16-sign-sg.tiktokcdn.com/aweme/720x720/tos-alisg-avt-0068/4eada0876c5ae48c8ca290ca0ff51c93.jpeg?x-expires=1659128400&x-signature=F2YUnqkFVhd5AdMOM2k57JJNa2U%3D              12900          21400000                     39          641900000 6558418321485414402 cutybeautykhan         Beauty khan           "Hi"                                                                                  true                                2054        14900 1587461917 2020-04-21T09:38:37.000Z   2500000 false      <NA>                  <NA>                                                          NA <NA>                  <NA>                                                          NA <NA>               1629042268403717 jiya_khan         <NA>                                                                                                                                                                       <NA>               15787069         cutebeuty         <NA>                                            6818097008646032641 https://v16-webapp.tiktok.com/9f206361bfc35f5556198fe3f1b52f2d/62e205e7/video/tos/useast2a/tos-useast2a-ve-0068c001/a0c00b2c05734df98957125ae8ef6ddf/?a=1988&ch=0&cr=0&dr=0&lr=tiktok_m&cd=0%7C0%7C1%7C0&cv=1&br=5804&bt=2902&btag=80000&cs=0&ds=3&ft=gKSYZ8fuo0PD1lY.psg9wIF2O5LiaQ2D~6a&mime_type=video_mp4&qs=0&rc=N2QzNjpkOTlnNTU8Z2g7NEBpamg5cXc1OjRldDMzNjczM0BhMy80XjViXi8xNDI1L19hYSNpNm9mLjFrcmNfLS0vMTZzcw%3D%3D&l=202207272143190102170192260264CEB8 @cuteipiejiya    <NA>                    <NA>          <NA>         <NA>         <NA>         Laxed - Siren Beat     Jawsh 685               Laxed                 false                     https://sf16-ies-music-va.tiktokcdn.com/obj/tos-useast2a-ve-2774/98f717da273b4c52ae7ec1d520194f2d  32500000 tiktokdance          17.2B                      10400 #jiya_khan #cutebeuty #tiktok #tiktokcomedy #tiktokdance @cuteipiejiya                                                                                                 15               1024               576 https://www.tiktok.com/@cutybeautykhan/video/6818097008646032641        
3 https://p16-sign-va.tiktokcdn.com/musically-maliva-obj/64d0354d8b58c532b0a09169964c0bc3~c5_720x720.jpeg?x-expires=1659128400&x-signature=CBQ9cLy5x1ntilSR1SzpWxO%2BLow%3D             27900           6100000                    422           51500000 6806465339817673733 thejohnnydshow         John Di Domenico      "John Di Domenico \r\nEmmy Nominated, Award Winning\r\nComedian, Actor, Impersonator" true                                 373        19500 1588643612 2020-05-05T01:53:32.000Z   2400000 false      <NA>                  <NA>                                                          NA <NA>                  <NA>                                                          NA <NA>               38970            trump             <NA>                                                                                                                                                                       <NA>               1606334392378370 comedy            <NA>                                            6823172346300484869 https://v16-webapp.tiktok.com/9ac3f9ed25a7ddda5d01e397e534ef7a/62e205e7/video/tos/useast2a/tos-useast2a-ve-0068c004/f9914dec2cd8421580100b491ae146cb/?a=1988&ch=0&cr=0&dr=0&lr=tiktok_m&cd=0%7C0%7C1%7C0&cv=1&br=2942&bt=1471&btag=80000&cs=0&ds=3&ft=gKSYZ8fuo0PD1lY.psg9wIF2O5LiaQ2D~6a&mime_type=video_mp4&qs=0&rc=OzpkNjo0ZjwzNGdnaGg6aEBpM2xuNTk8dDdmdDMzZzczM0A2NmFfYy41XmIxXjAuX2AvYSNtXmdiZW5wYmxfLS1fMTZzcw%3D%3D&l=202207272143190102170192260264CEB8 @johndidomenico  <NA>                    <NA>          <NA>         <NA>         <NA>         Laxed - Siren Beat     Jawsh 685               Laxed                 false                     https://sf16-ies-music-va.tiktokcdn.com/obj/tos-useast2a-ve-2774/491ebe57a5f7445c8258f3d39a65bf0a  38700000 tiktokdance          17.2B                      77500 #trump #comedy #tiktokdance #fyp @johndidomenico                                                                                                                       15               1024               576 https://www.tiktok.com/@thejohnnydshow/video/6823172346300484869        
4 https://p16-sign-va.tiktokcdn.com/musically-maliva-obj/1651531957900293~c5_720x720.jpeg?x-expires=1659128400&x-signature=FaRAg%2BaUfvcIp0rKHcGppfQmCNg%3D                                38            251100                      0            2600000 6764660438212592646 tiktok.dance.tuttorial dance tutorials ✌️     "MMTHANKYOU\r\nscorDN"                                                                false                                  2         5400 1575093425 2019-11-30T05:57:05.000Z   2400000 false      <NA>                  <NA>                                                          NA <NA>                  <NA>                                                          NA <NA>               88764338         foryoupage        <NA>                                                                                                                                                                       <NA>               42164            foryou            <NA>                                            6764974729607597318 https://v16-webapp.tiktok.com/8e605da6abb83a28b9dcd22fe1279bf2/62e205fa/video/tos/useast2a/tos-useast2a-ve-0068/ed3c60755e1c4830ad420f6e9785e239/?a=1988&ch=0&cr=0&dr=0&lr=tiktok_m&cd=0%7C0%7C1%7C0&cv=1&br=1228&bt=614&btag=80000&cs=0&ds=3&ft=eXd.6HQ9Myq8Z..x5we2NLH6yl7Gb&mime_type=video_mp4&qs=0&rc=NDw4aTQ8NTk0OjlpZ2dnN0BpM206amd2ZzgzcTMzZTczM0AzYjBeMDAvXmIxNV8tMS0zYSMvM2NsYmQ0NmVfLS1jMTZzcw%3D%3D&l=202207272143270102170191440C61812C            <NA>             <NA>                    <NA>          <NA>         <NA>         <NA>         <NA>                   dance tutorials ✌️       original sound        true                      https://sf16-ies-music-va.tiktokcdn.com/obj/musically-maliva-obj/1651604113076277.mp3              16700000 tiktokdance          17.2B                     198000 tutorial on how to do “american boy” #foryoupage #foryou #fyp #dancetutorial #tiktok #tiktokdance #itsblackfriday #happythanksgiving #vsco #dance#fy                   27                960               540 https://www.tiktok.com/@tiktok.dance.tuttorial/video/6764974729607597318
5 https://p16-sign-sg.tiktokcdn.com/aweme/720x720/tos-alisg-avt-0068/4eada0876c5ae48c8ca290ca0ff51c93.jpeg?x-expires=1659128400&x-signature=F2YUnqkFVhd5AdMOM2k57JJNa2U%3D              12900          21400000                     39          641900000 6558418321485414402 cutybeautykhan         Beauty khan           "Hi"                                                                                  true                                2054        12200 1591270930 2020-06-04T11:42:10.000Z   2400000 false      <NA>                  <NA>                                                          NA <NA>                  <NA>                                                          NA <NA>               18693583         tiktokcomedy      <NA>                                                                                                                                                                       <NA>               15787069         cutebeuty         <NA>                                            6834456591979367682 https://v16-webapp.tiktok.com/a749b70fba1ca94f224432f45783fa41/62e205eb/video/tos/useast2a/tos-useast2a-pve-0068/b67230c2c6a6403f8b6e6be83c9fffe7/?a=1988&ch=0&cr=0&dr=0&lr=tiktok_m&cd=0%7C0%7C1%7C0&cv=1&br=3404&bt=1702&btag=80000&cs=0&ds=3&ft=eXd.6HQ9Myq8Z..x5we2NLH6yl7Gb&mime_type=video_mp4&qs=0&rc=ZGZnZmc8PDg7NDM1O2Y8NkBpM2k1NHVrN3dndTMzZjczM0BfYy1gNl8uNi4xYDUuYy4xYSNmYWhtMHJlb2BfLS1eMTZzcw%3D%3D&l=202207272143270102170191440C61812C          @__angel_sneha__ @arbaz_mallick_official @cuteipiejiya <NA>         <NA>         <NA>         <NA>                   Zia_sulthan1            original sound        true                      https://sf16-ies-music-va.tiktokcdn.com/obj/musically-maliva-obj/1638348581178406.mp3              35600000 tiktokdance          17.2B                      17200 #tiktokcomedy #cutebeuty #tiktokdance @__angel_sneha__ @arbaz_mallick_official @cuteipiejiya                                                                           12               1024               576 https://www.tiktok.com/@cutybeautykhan/video/6834456591979367682        
6 https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/b79df7b3a90aecfcca1455a564dd0b3d~c5_720x720.jpeg?x-expires=1659128400&x-signature=b6CubmaoeMTCwKidPywfNZXL6a4%3D               195200             44000                   1336            2900000 6687361564112733189 julespods              jules                 "hello there"                                                                         false                                  5         7317 1583475241 2020-03-06T06:14:01.000Z   2300000 false      <NA>                  <NA>                                                          NA <NA>                  <NA>                                                          NA <NA>               229207           fyp               <NA>                                                                                                                                                                       <NA>               42164            foryou            <NA>                                            6800974337714261253 https://v16-webapp.tiktok.com/b2290f1e35fb5747dcb2a2b0765f736b/62e2060f/video/tos/useast2a/tos-useast2a-pve-0068/50f001a9320642d7a3dbc10dee5e0c7c/?a=1988&ch=0&cr=0&dr=0&lr=tiktok_m&cd=0%7C0%7C1%7C0&cv=1&br=3858&bt=1929&btag=80000&cs=0&ds=3&ft=eXd.6HQ9Myq8Z..x5we2NLH6yl7Gb&mime_type=video_mp4&qs=0&rc=NWU4OGg5aDU4NmgzaDozOEBpM20zdG9uMzd4czMzPDczM0BiXmA2YWE2X14xMi4xLzYvYSNfaGRjX18zZ2RfLS0uMTZzcw%3D%3D&l=202207272143270102170191440C61812C          <NA>             <NA>                    <NA>          <NA>         <NA>         <NA>         <NA>                   Steven & Archie         original sound        true                      https://sf16-ies-music-va.tiktokcdn.com/obj/musically-maliva-obj/1656476600046613.mp3               8600000 tiktokdance          17.2B                      53000 what our pep assemblies are like  #fyp #foryou #pepassembly #tiktokdance #dance                                                                                        48               1280               720 https://www.tiktok.com/@julespods/video/6800974337714261253             
7 https://p16-sign-sg.tiktokcdn.com/aweme/720x720/tos-alisg-avt-0068/4eada0876c5ae48c8ca290ca0ff51c93.jpeg?x-expires=1659128400&x-signature=F2YUnqkFVhd5AdMOM2k57JJNa2U%3D              12900          21400000                     39          641900000 6558418321485414402 cutybeautykhan         Beauty khan           "Hi"                                                                                  true                                2054        17100 1590213794 2020-05-23T06:03:14.000Z   2300000 false      <NA>                  <NA>                                                          NA <NA>                  <NA>                                                          NA <NA>               57511693         tiktokindia       Be the change.musical.ly is now TikTok@indiatiktok #tiktokindia                                                                                                            <NA>               15787069         cutebeuty         <NA>                                            6829916227352284417 https://v16-webapp.tiktok.com/146ecf998365aa4d753d2cd4be4d8767/62e205ed/video/tos/useast2a/tos-useast2a-ve-0068c002/ef539f034d434343b42b56172ad0fb11/?a=1988&ch=0&cr=0&dr=0&lr=tiktok_m&cd=0%7C0%7C1%7C0&cv=1&br=3616&bt=1808&btag=80000&cs=0&ds=3&ft=eXd.6HQ9Myq8Z..x5we2NLH6yl7Gb&mime_type=video_mp4&qs=0&rc=PDw2NTU2PGVnM2k4aGg1NEBpajQ3bTl4NzNldTMzOzczM0BhLzQyNGAwNjUxLmJgMmJeYSNvbGtpLTIxbTFfLS1iMTZzcw%3D%3D&l=202207272143270102170191440C61812C       @__angel_sneha__ @arbaz_mallick_official @cuteipiejiya <NA>         <NA>         <NA>         Pogaru                 Chandan Shetty          Karabuu               false                     <NA>                                                                                               27400000 tiktokdance          17.2B                      10400 #tiktokindia #cutebeuty #tiktokdance @__angel_sneha__ @arbaz_mallick_official @cuteipiejiya                                                                            14               1024               576 https://www.tiktok.com/@cutybeautykhan/video/6829916227352284417        
8 https://p16-sign-va.tiktokcdn.com/musically-maliva-obj/64d0354d8b58c532b0a09169964c0bc3~c5_720x720.jpeg?x-expires=1659128400&x-signature=CBQ9cLy5x1ntilSR1SzpWxO%2BLow%3D             27900           6100000                    422           51500000 6806465339817673733 thejohnnydshow         John Di Domenico      "John Di Domenico \r\nEmmy Nominated, Award Winning\r\nComedian, Actor, Impersonator" true                                 373        32600 1595019999 2020-07-17T21:06:39.000Z   2300000 false      <NA>                  <NA>                                                          NA <NA>                  <NA>                                                          NA <NA>               11251            go                Ever feel like telling somebody to just GO? We do too! Make a #GoChallenge musical.ly to @VBozeman's new song and she'll give a social shout out and a prize to her faves! <NA>               95636            gogogo            魔性音樂接力挑戰,gogogo 誰會是下一個接力達人? 6850558720049515781 https://v16-webapp.tiktok.com/cf96a20cfdc7a0e28f85f38b49fbd472/62e205e9/video/tos/useast2a/tos-useast2a-ve-0068c002/f8e78dc86aa2454bb673b8ec4974bc87/?a=1988&ch=0&cr=0&dr=0&lr=tiktok_m&cd=0%7C0%7C1%7C0&cv=1&br=2980&bt=1490&btag=80000&cs=0&ds=3&ft=eXd.6HQ9Myq8Z..x5we2NLH6yl7Gb&mime_type=video_mp4&qs=0&rc=NmQ5NGg4OjxoZjY6NGY5aEBpanQ0bjgzM3A0djMzODczM0AtNS01L14vNWExXzBjNS0zYSNsMC00LmYyMjZfLS1hMTZzcw%3D%3D&l=202207272143270102170191440C61812C       @johndidomenico  <NA>                    <NA>          <NA>         <NA>         <NA>         Go Go Go Who's Next?   Hip Hop Harry           Go Go Go Who's Next?  false                     https://sf16-ies-music-va.tiktokcdn.com/obj/tos-useast2a-ve-2774/d7367ee036094bbfa7844052976dad25  28500000 tiktokdance          17.2B                      48500 #go #gogogo #whosnext #trump #trump2020 #tiktokdance #thejohnald @johndidomenico                                                                                       10               1024               576 https://www.tiktok.com/@thejohnnydshow/video/6850558720049515781        
# https://www.kaggle.com/datasets/sveta151/tiktok-popular-songs-2019
tiktok_songs_py = pandas.read_csv("../../dataset/tiktok-songs-2019.csv")
tiktok_songs_py.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 223 entries, 0 to 222
Data columns (total 18 columns):
 #   Column            Non-Null Count  Dtype  
---  ------            --------------  -----  
 0   track_name        223 non-null    object 
 1   artist_name       223 non-null    object 
 2   artist_pop        223 non-null    int64  
 3   album             223 non-null    object 
 4   track_pop         223 non-null    int64  
 5   danceability      223 non-null    float64
 6   energy            223 non-null    float64
 7   loudness          223 non-null    float64
 8   mode              223 non-null    int64  
 9   key               223 non-null    int64  
 10  speechiness       223 non-null    float64
 11  acousticness      223 non-null    float64
 12  instrumentalness  223 non-null    float64
 13  liveness          223 non-null    float64
 14  valence           223 non-null    float64
 15  tempo             223 non-null    float64
 16  time_signature    223 non-null    int64  
 17  duration_ms       223 non-null    int64  
dtypes: float64(9), int64(6), object(3)
memory usage: 31.5+ KB
tiktok_songs_py.head(n=8)
             track_name                 artist_name  artist_pop                 album  track_pop  danceability  energy  loudness  mode  key  speechiness  acousticness  instrumentalness  liveness  valence    tempo  time_signature  duration_ms
0              Shake It               Metro Station          53         Metro Station         68         0.618   0.955    -3.836     1    4       0.0798       0.00221          0.000003    0.4860    0.790  150.034               4       179947
1      Chinese New Year                       SALES          61            SALES - EP         53         0.744   0.845    -7.422     0    4       0.2530       0.75900          0.232000    0.1000    0.749   75.221               4       160000
2        Baby I'm Yours                    Breakbot          57          By Your Side         69         0.829   0.792    -3.755     0    2       0.0668       0.72600          0.000006    0.1220    0.758  118.050               4       215507
3            The Git Up                Blanco Brown          60            The Git Up          2         0.847   0.678    -8.635     1    9       0.1090       0.06690          0.000000    0.2740    0.811   97.984               4       200594
4  Say Hey (I Love You)  Michael Franti & Spearhead          58     All Rebel Rockers          0         0.738   0.983    -4.374     0    5       0.0855       0.03800          0.000006    0.1830    0.957   92.998               4       235760
5         Falling for U                     Peachy!          57         Falling for U          1         0.516   0.358   -12.018     0    8       0.4240       0.74300          0.000001    0.0813    0.397   79.509               4       124000
6        Shooting Stars                 Bag Raiders          53  Bag Raiders (Deluxe)          0         0.649   0.716    -6.232     1   11       0.0445       0.08790          0.030000    0.0824    0.503  124.968               4       235813
7                  fast                       Sueco          65                  fast          0         0.877   0.503   -10.269     0    7       0.2200       0.16400          0.013200    0.1020    0.529  100.069               4       144000
tiktok_songs_py.tail(n=8)
                       track_name             artist_name  artist_pop                                        album  track_pop  danceability  energy  loudness  mode  key  speechiness  acousticness  instrumentalness  liveness  valence    tempo  time_signature  duration_ms
215                   Stereo Love             Edward Maya          64                         The Stereo Love Show         18         0.771   0.728    -6.809     1    9       0.0359       0.01740          0.029900    0.0779    0.297  127.019               4       320637
216  Never Ever Getting Rid of Me  Christopher Fitzgerald          48  Waitress (Original Broadway Cast Recording)         63         0.622   0.542    -6.215     0    7       0.0510       0.38700          0.000000    0.1140    0.939  174.494               4       136200
217             Wanna Be Like You                   Jacob           4                            Wanna Be Like You         17         0.816   0.363   -10.362     1    5       0.1010       0.48700          0.000003    0.2050    0.595  104.274               4       229415
218          Skinny Legend Anthem              Ava Louise          32                         Skinny Legend Anthem         50         0.845   0.518    -7.568     1   11       0.2990       0.07030          0.000000    0.1220    0.443  129.951               4       135993
219                 Material Girl                 Madonna          77            Celebration (double disc version)         78         0.742   0.883    -3.419     1    0       0.0329       0.33300          0.000008    0.0964    0.978  136.506               4       240280
220           I Wish - Radio Edit                 Skee-Lo          51                                       I Wish         63         0.715   0.738   -10.139     1    7       0.1570       0.00826          0.000000    0.2600    0.573   97.877               4       252307
221         Oh No I Got a Disease               Buss Crew          11                        Oh No I Got a Disease         26         0.649   0.735    -4.365     0   10       0.7300       0.14600          0.000000    0.1240    0.845   86.704               5       134769
222                         Woahh                    Jufu          31                                        Woahh         22         0.749   0.283   -12.368     0    0       0.3280       0.61800          0.000004    0.0825    0.269  142.046               4       172888
# https://www.kaggle.com/datasets/sveta151/tiktok-popular-songs-2019
# Semicolon prevents the variable from being printed
tiktok_songs_jl = CSV.File("../../dataset/tiktok-songs-2019.csv") |> DataFrames.DataFrame
223×18 DataFrame
 Row │ track_name                         artist_name                 artist_pop  album                              track_pop  danceability  energy   loudness  mode   key    speechiness  acousticness  instrumentalness  liveness  valence  tempo    time_signature  duration_ms
     │ String                             String31                    Int64       String                             Int64      Float64       Float64  Float64   Int64  Int64  Float64      Float64       Float64           Float64   Float64  Float64  Int64           Int64
─────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1 │ Shake It                           Metro Station                       53  Metro Station                             68         0.618    0.955    -3.836      1      4       0.0798      0.00221           3.09e-6     0.486     0.79   150.034               4       179947
   2 │ Chinese New Year                   SALES                               61  SALES - EP                                53         0.744    0.845    -7.422      0      4       0.253       0.759             0.232       0.1       0.749   75.221               4       160000
   3 │ Baby I'm Yours                     Breakbot                            57  By Your Side                              69         0.829    0.792    -3.755      0      2       0.0668      0.726             5.83e-6     0.122     0.758  118.05                4       215507
   4 │ The Git Up                         Blanco Brown                        60  The Git Up                                 2         0.847    0.678    -8.635      1      9       0.109       0.0669            0.0         0.274     0.811   97.984               4       200594
   5 │ Say Hey (I Love You)               Michael Franti & Spearhead          58  All Rebel Rockers                          0         0.738    0.983    -4.374      0      5       0.0855      0.038             5.93e-6     0.183     0.957   92.998               4       235760
   6 │ Falling for U                      Peachy!                             57  Falling for U                              1         0.516    0.358   -12.018      0      8       0.424       0.743             1.3e-6      0.0813    0.397   79.509               4       124000
   7 │ Shooting Stars                     Bag Raiders                         53  Bag Raiders (Deluxe)                       0         0.649    0.716    -6.232      1     11       0.0445      0.0879            0.03        0.0824    0.503  124.968               4       235813
   8 │ fast                               Sueco                               65  fast                                       0         0.877    0.503   -10.269      0      7       0.22        0.164             0.0132      0.102     0.529  100.069               4       144000
   9 │ On A Roll                          Ashley O                            43  On A Roll                                 58         0.736    0.81     -6.354      1      5       0.0906      0.077             0.0         0.0523    0.387  125.011               4       154448
  10 │ Good Girls Bad Guys                Falling In Reverse                  70  The Drug In Me Is You                     64         0.474    0.948    -2.592      1      3       0.122       0.0223            0.0         0.43      0.611  146.46                4       195373
  11 │ Just Did a Bad Thing               Bill Wurtz                          43  Just Did a Bad Thing                      43         0.754    0.526   -12.96       1      1       0.0435      0.00261           0.466       0.113     0.716  117.051               4       167180
  12 │ Wait a Minute!                     WILLOW                              76  ARDIPITHECUS                              86         0.764    0.705    -5.279      0      3       0.0278      0.0371            1.94e-5     0.0943    0.672  101.003               4       196520
  13 │ Spooky, Scary Skeletons            Andrew Gold                         49  Halloween Howls: Fun & Scary Mus…         50         0.806    0.447   -10.181      1      7       0.0461      0.27              3.7e-6      0.335     0.914   77.033               5       127627
  14 │ Livin' in the Sunlight, Lovin' i…  Tiny Tim                            41  God Bless Tiny Tim                        51         0.603    0.276   -19.238      1      4       0.0871      0.911             0.00237     0.484     0.86    99.561               4       125933
  15 │ Tell Me Something I Don't Know -…  Selena Gomez                        80  Another Cinderella Story (Origin…         56         0.611    0.936    -3.697      0      7       0.11        0.0309            0.0         0.12      0.697  144.901               4       201427
  16 │ STUPID (feat. Yung Baby Tate)      Ashnikko                            69  Hi, It's Me                               70         0.772    0.637    -6.881      1      2       0.114       0.00459           0.0         0.0778    0.54   149.906               4       167317
  17 │ Beef FloMix                        Flo Milli                           67  Beef FloMix                               53         0.857    0.575    -8.36       1      7       0.221       0.239             0.0         0.293     0.901  116.993               4       147692
  18 │ Prom Queen                         Beach Bunny                         70  Prom Queen                                80         0.528    0.797    -7.487      1      4       0.0485      0.000391          0.011       0.14      0.751  143.785               4       136562
  19 │ Don't Lose Ur Head                 SIX                                 61  Six: The Musical (Studio Cast Re…         66         0.859    0.605    -7.635      0      7       0.357       0.251             0.0         0.132     0.722   82.91                4       245303
  20 │ Legs (From "RuPaul's Drag Race 8…  Lucian Piane                        32  Legs (From "RuPaul's Drag Race 8…         44         0.9      0.72     -5.486      0      5       0.232       0.00502           6.26e-6     0.543     0.749  122.994               4       106364
  21 │ Woah (feat. D3Mstreet)             KRYPTO9095                          39  Woah (feat. D3Mstreet)                    56         0.888    0.522    -8.936      1      1       0.43        0.00739           0.0         0.0452    0.623  144.011               4       123373
  22 │ Steppin'                           Supa Dupa Humble                    38  Steppin'                                  55         0.85     0.58     -4.502      1      1       0.104       0.000404          0.0821      0.0714    0.12   160.055               4       145253
  23 │ Hungry Hippo                       Tierra Whack                        58  Whack World                               57         0.893    0.61     -5.691      0      4       0.0488      0.0227            0.00744     0.102     0.778  136.64                4        60000
  24 │ I'm Sorry                          Swell                               47  Theres Still Us                            0         0.944    0.541    -9.61       0      6       0.166       0.0879            0.000119    0.033     0.724  134.942               4       157333
  25 │ Vibin'                             Kesh Kesh                           27  Vibin'                                    41         0.686    0.805    -6.816      0     11       0.154       0.00478           1.09e-6     0.0887    0.289  130.981               4       154567
  26 │ Fly Me To The Moon (In Other Wor…  Frank Sinatra                       74  Sinatra/Basie: The Complete Repr…         71         0.668    0.26    -14.256      1      7       0.0523      0.453             0.0         0.0621    0.368  119.416               4       147000
  27 │ Yellow Hearts                      Ant Saunders                        52  Yellow Hearts                              0         0.866    0.399   -10.938      1      7       0.0745      0.117             0.0         0.0689    0.713  129.047               4       223256
  28 │ Old Town Road                      Lil Nas X                           81  7 EP                                      76         0.907    0.53     -6.112      1      1       0.127       0.0578            2.23e-6     0.101     0.507  135.998               4       113000
  29 │ I Don't Mind (feat. Juicy J)       Usher                               78  I Don't Mind (feat. Juicy J)              67         0.87     0.464    -8.337      1      4       0.178       0.205             0.0         0.0902    0.457  112.974               4       251989
  30 │ ROXANNE                            Arizona Zervas                      66  ROXANNE                                   78         0.621    0.601    -5.616      0      6       0.148       0.0522            0.0         0.46      0.457  116.735               5       163636
  31 │ American Boy                       Estelle                             65  Shine                                     78         0.727    0.729    -2.99       1      0       0.326       0.171             0.0         0.07      0.512  117.932               4       284733
  32 │ Beggin (original version)          Madcon                              61  So Dark The Con Of Man                    70         0.715    0.8      -5.144      0      4       0.057       0.0271            0.0         0.0648    0.445  129.023               4       216147
  33 │ Put Your Head on My Shoulder       Paul Anka                           59  Sings His Favorites                       63         0.549    0.433    -8.526      1      7       0.0327      0.906             0.0108      0.0774    0.486  116.068               3       155080
  34 │ prom dress                         mxmtoon                             67  the masquerade                            73         0.56     0.674    -6.048      1     10       0.0446      0.698             0.0         0.123     0.421  119.942               4       197933
  35 │ Criminal                           Britney Spears                      78  Femme Fatale (Deluxe Version)             71         0.696    0.734    -5.294      1      7       0.0298      0.0485            0.0         0.183     0.711  107.987               4       225080
  36 │ Runway                             Stunna Girl                         45  YKWTFGO                                   47         0.638    0.912    -3.3        1      1       0.474       0.0155            0.0         0.234     0.725  190.178               4       152464
  37 │ It's The Hard-Knock Life           Quvenzhané Wallis                   45  Annie (Original Motion Picture S…         53         0.738    0.841    -5.352      1      9       0.0924      0.0452            0.0105      0.03      0.836  163.913               4       130467
  38 │ Faucet Failure                     Ski Mask The Slump God              75  STOKELEY                                  75         0.935    0.552    -9.373      0     10       0.335       0.111             0.0         0.0952    0.615   99.993               4       145627
  39 │ Buttercup                          Jack Stauber                        62  Pop Food                                  72         0.705    0.373    -9.066      1      7       0.0384      0.723             0.81        0.289     0.551  120.046               4       208026
  40 │ Hey Julie! (feat. Lil Yachty)      KYLE                                65  Light of Mine (Deluxe)                    55         0.803    0.499    -5.932      1     11       0.306       0.0363            3.46e-6     0.129     0.749  161.042               4       156637
  41 │ Uno                                Ambjaay                             41  Uno                                       56         0.978    0.477    -8.159      1      8       0.155       0.000143          0.0         0.133     0.196  110.002               4       109091
  42 │ Tunnel of Love                     ilyTOMMY                            61  Tunnel of Love                            58         0.683    0.636   -12.096      0      7       0.0978      0.302             0.498       0.0972    0.615  160.012               4       142365
  43 │ Walk Man                           Tiny Meat Gang                      52  Walk Man                                  59         0.928    0.696    -4.972      0      4       0.0866      0.331             0.000119    0.121     0.396   94.994               4       165938
  44 │ CRACKHEAD                          iLOVEFRiDAY                         42  CRACKHEAD                                 31         0.746    0.419    -9.083      1      5       0.478       0.0828            0.00457     0.561     0.421  145.059               4        43427
  45 │ Fake ID                            Riton                               68  Foreign Ororo (Special Edition)           63         0.746    0.862    -6.11       1      8       0.0776      0.21              0.0363      0.225     0.604  122.011               4       246970
  46 │ Wasabi                             Little Mix                          77  LM5 (Deluxe)                              66         0.847    0.656    -4.976      1      2       0.115       0.00451           0.000854    0.143     0.234  114.001               4       154787
  ⋮  │                 ⋮                              ⋮                   ⋮                       ⋮                      ⋮           ⋮           ⋮        ⋮        ⋮      ⋮         ⋮            ⋮               ⋮             ⋮         ⋮        ⋮           ⋮              ⋮
 179 │ A Thousand Years                   Christina Perri                     70  A Thousand Years                          80         0.421    0.407    -7.445      1     10       0.0267      0.309             0.000961    0.11      0.161  139.028               3       285120
 180 │ Mr. Saxobeat - Radio Edit          Alexandra Stan                      61  Sundown (Original Motion Picture…          0         0.72     0.925    -4.165      0      4       0.0511      0.0276            0.000238    0.14      0.781  127.004               4       195105
 181 │ We R Who We R                      Kesha                               76  Cannibal (Expanded Edition)               72         0.736    0.817    -4.9        1      8       0.0407      0.00987           0.00167     0.117     0.653  119.95                4       204760
 182 │ Crank That (Soulja Boy)            Soulja Boy                          69  souljaboytellem.com                       74         0.736    0.74     -2.18       1      0       0.0786      0.515             0.0         0.0468    0.803  140.141               4       221933
 183 │ No More ?'s                        Eazy-E                              64  Eazy-Duz-It                               69         0.935    0.805    -4.782      1      7       0.225       0.0143            1.53e-6     0.298     0.624  105.641               4       234360
 184 │ Y U Gotta B Like That              Audrey Mika                         56  Y U Gotta B Like That                     58         0.732    0.413    -6.353      1      9       0.0702      0.287             0.0         0.0565    0.761   92.066               4       154456
 185 │ Kill the Director                  The Wombats                         65  Proudly Present... A Guide to Lo…         64         0.41     0.858    -5.295      0      1       0.0485      0.00347           0.0         0.0897    0.962  161.487               4       161560
 186 │ Ligma                              Billy Marchiafava                   53  Ligma                                     49         0.937    0.397    -9.414      1      8       0.418       0.0915            0.0         0.0919    0.603  128.561               4        75717
 187 │ Airplane Mode                      Limbo                               50  Holo                                       0         0.665    0.373   -10.631      1      7       0.158       0.852             0.118       0.108     0.07   119.905               4       164113
 188 │ It's You                           Ali Gatie                           70  It's You                                   5         0.732    0.463    -6.972      0     11       0.0287      0.374             0.0         0.194     0.397   95.971               4       212607
 189 │ Baby Yoda                          Song a Day                          25  Baby Yoda                                 38         0.822    0.408   -16.616      1      2       0.206       0.373             0.0685      0.118     0.848  160.074               4        87000
 190 │ Monsters, Inc.                     Randy Newman                        60  Monsters, Inc. (Original Motion …         55         0.68     0.465    -8.353      1      8       0.029       0.743             0.676       0.136     0.847  109.972               4       126387
 191 │ hot girl bummer                    blackbear                           79  hot girl bummer                            5         0.778    0.559    -7.109      0      6       0.0776      0.128             0.0         0.399     0.678  129.989               1       185093
 192 │ Get Down                           SIX                                 61  Six: The Musical (Studio Cast Re…         61         0.898    0.406    -9.905      0      4       0.102       0.00986           0.0         0.0509    0.39   102.985               4       253993
 193 │ Falling                            Trevor Daniel                       65  Nicotine                                   3         0.784    0.43     -8.756      0     10       0.0364      0.123             0.0         0.0887    0.236  127.087               4       159382
 194 │ successful                         Ariana Grande                       87  Sweetener                                 65         0.847    0.603    -4.607      0      0       0.0397      0.107             7.4e-6      0.106     0.735  114.045               4       227387
 195 │ Chucky Cheese                      MadeinTYO                           62  Sincerely, Tokyo                          55         0.89     0.542    -4.826      0     10       0.314       0.523             0.0         0.123     0.565   78.458               4       165293
 196 │ Sin City                           Chrishan                            42  Sin City                                  58         0.886    0.225   -11.437      1      4       0.457       0.676             0.0         0.0938    0.387  120.1                 4       212000
 197 │ MICKEY                             Lil Yachty                          75  Lil Boat 2                                54         0.971    0.465    -5.655      1      1       0.23        0.0295            0.0         0.097     0.131  119.994               4       160518
 198 │ Another Day Of Sun                 La La Land Cast                     46  La La Land (Original Motion Pict…         64         0.588    0.742    -6.757      1      8       0.0528      0.0162            3.98e-6     0.653     0.824  125.819               4       228173
 199 │ Forget Me Thots                    Yung Gravy                          75  Yung Gravity - EP                         58         0.887    0.737    -6.489      0      6       0.16        0.243             4.11e-5     0.109     0.685  104.924               4       184000
 200 │ Act Up                             City Girls                          67  Girl Code                                 67         0.938    0.638    -4.713      1      8       0.189       0.0167            0.0         0.111     0.313   97.075               4       158332
 201 │ This Is for Rachel                 Gxrrixon                             0  This Is for Rachel                         0         0.9      0.461   -14.453      1      8       0.515       0.161             1.78e-6     0.089     0.35    96.985               4       165698
 202 │ Hokus Pokus                        Insane Clown Posse                  63  The Great Milenko                         62         0.87     0.841    -5.084      0     11       0.0948      0.0193            7.71e-5     0.333     0.857   92.176               4       261173
 203 │ 恋愛サーキュレーション             物語シリーズ                        53  Utamonogatari Special Edition (O…         65         0.814    0.785    -5.679      0      1       0.0396      0.0524            0.00111     0.111     0.941  120.009               4       255040
 204 │ WTF                                Young Spool                          3  WTF                                        0         0.819    0.791    -5.736      1      8       0.324       0.372             6.22e-5     0.471     0.902  172.094               4        89293
 205 │ 223's (feat. 9lokknine)            YNW Melly                           73  Melly vs. Melvin                          66         0.932    0.547    -7.787      0      0       0.333       0.0388            0.0         0.0924    0.695   94.998               4       176640
 206 │ cheatercheaterbestfriendeater      Never Shout Never                   49  Harmony                                   49         0.768    0.683    -7.173      1      7       0.0604      0.388             0.0         0.286     0.669   99.955               4       178144
 207 │ Myself                             Bazzi                               72  COSMIC                                    67         0.745    0.561    -5.513      0      9       0.072       0.465             1.12e-6     0.0338    0.902  195.918               4       167553
 208 │ Obsessed                           Mariah Carey                        76  Memoirs of an imperfect Angel (I…         68         0.742    0.468    -5.557      0     10       0.0625      0.0465            0.0         0.826     0.369   86.443               4       242200
 209 │ GOODMORNINGTOKYO!                  TOKYO’S REVENGE                     59  GOODMORNINGTOKYO!                         70         0.907    0.539    -7.782      1      4       0.36        0.0408            0.0         0.253     0.664  124.918               4       150115
 210 │ Walked In                          Ultradiox                           29  Orichalcos                                42         0.891    0.538    -6.724      1      2       0.394       0.123             0.0         0.0848    0.643   80.032               4       107404
 211 │ Psycho!                            MASN                                60  Psycho!                                    0         0.868    0.365    -9.51       1      7       0.0383      0.433             0.0         0.207     0.471  114.979               4       197217
 212 │ You Need To Calm Down              Taylor Swift                        93  Lover                                     76         0.771    0.671    -5.617      1      2       0.0553      0.00929           0.0         0.0637    0.714   85.026               4       171360
 213 │ Moskau                             Dschinghis Khan                     49  7 Leben                                   59         0.676    0.724    -5.941      0      5       0.039       0.0681            9.29e-5     0.139     0.676  132.056               4       221373
 214 │ Big Fun                            Jon Eidson                          44  Heathers: The Musical (World Pre…         54         0.864    0.681    -6.032      1      8       0.232       0.538             0.0         0.555     0.734  118.061               4       254667
 215 │ Eenie Meenie                       Sean Kingston                       69  Eenie Meenie                              74         0.72     0.607    -4.168      1      1       0.0322      0.0543            0.0         0.113     0.828  121.223               4       201947
 216 │ Stereo Love                        Edward Maya                         64  The Stereo Love Show                      18         0.771    0.728    -6.809      1      9       0.0359      0.0174            0.0299      0.0779    0.297  127.019               4       320637
 217 │ Never Ever Getting Rid of Me       Christopher Fitzgerald              48  Waitress (Original Broadway Cast…         63         0.622    0.542    -6.215      0      7       0.051       0.387             0.0         0.114     0.939  174.494               4       136200
 218 │ Wanna Be Like You                  Jacob                                4  Wanna Be Like You                         17         0.816    0.363   -10.362      1      5       0.101       0.487             3.41e-6     0.205     0.595  104.274               4       229415
 219 │ Skinny Legend Anthem               Ava Louise                          32  Skinny Legend Anthem                      50         0.845    0.518    -7.568      1     11       0.299       0.0703            0.0         0.122     0.443  129.951               4       135993
 220 │ Material Girl                      Madonna                             77  Celebration (double disc version)         78         0.742    0.883    -3.419      1      0       0.0329      0.333             7.51e-6     0.0964    0.978  136.506               4       240280
 221 │ I Wish - Radio Edit                Skee-Lo                             51  I Wish                                    63         0.715    0.738   -10.139      1      7       0.157       0.00826           0.0         0.26      0.573   97.877               4       252307
 222 │ Oh No I Got a Disease              Buss Crew                           11  Oh No I Got a Disease                     26         0.649    0.735    -4.365      0     10       0.73        0.146             0.0         0.124     0.845   86.704               5       134769
 223 │ Woahh                              Jufu                                31  Woahh                                     22         0.749    0.283   -12.368      0      0       0.328       0.618             3.73e-6     0.0825    0.269  142.046               4       172888
                                                                                                                                                                                                                                                                    132 rows omitted

Wrangling Data

tiktok_songs_clean_r <- tiktok_songs_r

tiktok_songs_clean_r$mode <- factor(tiktok_songs_clean_r$mode)
tiktok_songs_clean_r$mode <- recode(tiktok_songs_clean_r$mode, "0" = "Minor", "1" = "Major")

tiktok_songs_clean_r$key <- ordered(factor(tiktok_songs_clean_r$key), levels=c("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"))
tiktok_songs_clean_r$key <- recode(tiktok_songs_clean_r$key, "0" = "C", "1" = "C#/Db", "2" = "D", "3" = "D#/Eb", "4" = "E", "5" = "F", "6" = "F#/Gb", "7" = "G", "8" = "G#/Ab", "9" = "A", "10" = "A#/Bb", "11" = "B")

tiktok_songs_clean_r$major_key <- paste(as.character(tiktok_songs_clean_r$key), as.character(tiktok_songs_clean_r$mode), sep=" ")
tiktok_songs_clean_r$major_key[tiktok_songs_clean_r$major_key == "A Minor"] <- "C Major"; tiktok_songs_clean_r$major_key[tiktok_songs_clean_r$major_key == "A#/Bb Minor"] <- "C#/Db Major"; tiktok_songs_clean_r$major_key[tiktok_songs_clean_r$major_key == "B Minor"] <- "D Major"; tiktok_songs_clean_r$major_key[tiktok_songs_clean_r$major_key == "C Minor"] <- "D#/Eb Major"; tiktok_songs_clean_r$major_key[tiktok_songs_clean_r$major_key == "C#/Db Minor"] <- "E Major"; tiktok_songs_clean_r$major_key[tiktok_songs_clean_r$major_key == "D Minor"] <- "F Major"; tiktok_songs_clean_r$major_key[tiktok_songs_clean_r$major_key == "D#/Eb Minor"] <- "F#/Gb Major"; tiktok_songs_clean_r$major_key[tiktok_songs_clean_r$major_key == "E Minor"] <- "G Major"; tiktok_songs_clean_r$major_key[tiktok_songs_clean_r$major_key == "F Minor"] <- "G#/Ab Major"; tiktok_songs_clean_r$major_key[tiktok_songs_clean_r$major_key == "F#/Gb Minor"] <- "A Major"; tiktok_songs_clean_r$major_key[tiktok_songs_clean_r$major_key == "G Minor"] <- "A#/Bb Major"; tiktok_songs_clean_r$major_key[tiktok_songs_clean_r$major_key == "G#/Ab Minor"] <- "B Major" 
tiktok_songs_clean_r$major_key <- ordered(factor(tiktok_songs_clean_r$major_key), levels=c("C Major", "C#/Db Major", "D Major", "D#/Eb Major", "E Major", "F Major", "F#/Gb Major", "G Major", "G#/Ab Major", "A Major", "A#/Bb Major", "B Major"))
tiktok_songs_clean_r$major_key <- recode(tiktok_songs_clean_r$major_key, "C Major" = "C Major (A Minor)", "C#/Db Major" = "C#/Db Major (A#/Bb Minor)", "D Major" = "D Major (B Minor)", "D#/Eb Major" = "D#/Eb Major (C Minor)", "E Major" = "E Major (C#/Db Minor)", "F Major" = "F Major (D Minor)", "F#/Gb Major" = "F#/Gb Major (D#/Eb Minor)", "G Major" = "G Major (E Minor)", "G#/Ab Major" = "G#/Ab Major (F Minor)", "A Major" = "A Major (F#/Gb Minor)", "A#/Bb Major" = "A#/Bb Major (G Minor)", "B Major" = "B Major (G#/Ab Minor)")

tiktok_songs_clean_r <- tiktok_songs_clean_r[, c("major_key", "key", "mode", "artist_name", "artist_pop", "track_name", "track_pop", "album", "duration_ms", "time_signature", "tempo", "valence","energy", "loudness", "instrumentalness", "acousticness", "liveness", "speechiness", "danceability")]

str(object=tiktok_songs_clean_r)
'data.frame':	223 obs. of  19 variables:
 $ major_key       : Ord.factor w/ 12 levels "C Major (A Minor)"<..: 5 8 6 10 9 12 12 11 6 4 ...
 $ key             : Ord.factor w/ 12 levels "C"<"C#/Db"<"D"<..: 5 5 3 10 6 9 12 8 6 4 ...
 $ mode            : Factor w/ 2 levels "Minor","Major": 2 1 1 2 1 1 2 1 2 2 ...
 $ artist_name     : Factor w/ 209 levels "24kGoldn","88rising",..: 128 153 32 29 129 139 19 167 14 61 ...
 $ artist_pop      : int  53 61 57 60 58 57 53 65 43 70 ...
 $ track_name      : Factor w/ 221 levels "223's (feat. 9lokknine)",..: 161 39 14 181 158 59 163 60 141 72 ...
 $ track_pop       : int  68 53 69 2 0 1 0 0 58 64 ...
 $ album           : Factor w/ 220 levels "#3 Deluxe Version",..: 117 146 26 177 9 52 19 53 129 174 ...
 $ duration_ms     : int  179947 160000 215507 200594 235760 124000 235813 144000 154448 195373 ...
 $ time_signature  : int  4 4 4 4 4 4 4 4 4 4 ...
 $ tempo           : num  150 75.2 118 98 93 ...
 $ valence         : num  0.79 0.749 0.758 0.811 0.957 0.397 0.503 0.529 0.387 0.611 ...
 $ energy          : num  0.955 0.845 0.792 0.678 0.983 0.358 0.716 0.503 0.81 0.948 ...
 $ loudness        : num  -3.84 -7.42 -3.75 -8.63 -4.37 ...
 $ instrumentalness: num  0.00000309 0.232 0.00000583 0 0.00000593 0.0000013 0.03 0.0132 0 0 ...
 $ acousticness    : num  0.00221 0.759 0.726 0.0669 0.038 0.743 0.0879 0.164 0.077 0.0223 ...
 $ liveness        : num  0.486 0.1 0.122 0.274 0.183 0.0813 0.0824 0.102 0.0523 0.43 ...
 $ speechiness     : num  0.0798 0.253 0.0668 0.109 0.0855 0.424 0.0445 0.22 0.0906 0.122 ...
 $ danceability    : num  0.618 0.744 0.829 0.847 0.738 0.516 0.649 0.877 0.736 0.474 ...
head(x=tiktok_songs_clean_r, n=7)
              major_key   key  mode                artist_name artist_pop           track_name track_pop                album duration_ms time_signature tempo valence energy loudness instrumentalness acousticness liveness speechiness danceability
1 E Major (C#/Db Minor)     E Major              Metro Station         53             Shake It        68        Metro Station      179947              4   150    0.79   0.95     -3.8        0.0000031       0.0022    0.486       0.080         0.62
2     G Major (E Minor)     E Minor                      SALES         61     Chinese New Year        53           SALES - EP      160000              4    75    0.75   0.84     -7.4        0.2320000       0.7590    0.100       0.253         0.74
3     F Major (D Minor)     D Minor                   Breakbot         57       Baby I'm Yours        69         By Your Side      215507              4   118    0.76   0.79     -3.8        0.0000058       0.7260    0.122       0.067         0.83
4 A Major (F#/Gb Minor)     A Major               Blanco Brown         60           The Git Up         2           The Git Up      200594              4    98    0.81   0.68     -8.6        0.0000000       0.0669    0.274       0.109         0.85
5 G#/Ab Major (F Minor)     F Minor Michael Franti & Spearhead         58 Say Hey (I Love You)         0    All Rebel Rockers      235760              4    93    0.96   0.98     -4.4        0.0000059       0.0380    0.183       0.086         0.74
6 B Major (G#/Ab Minor) G#/Ab Minor                    Peachy!         57        Falling for U         1        Falling for U      124000              4    80    0.40   0.36    -12.0        0.0000013       0.7430    0.081       0.424         0.52
7 B Major (G#/Ab Minor)     B Major                Bag Raiders         53       Shooting Stars         0 Bag Raiders (Deluxe)      235813              4   125    0.50   0.72     -6.2        0.0300000       0.0879    0.082       0.044         0.65
which(is.na(tiktok_songs_clean_r))
integer(0)

Let’s see how we implement the major components of Grammar of Graphics to tell various stories.

Theme

The theme I’ll use is a custom theme that I’ve created (but not without influence from elsewhere). As the famous quote from Oscar Wilde goes, “Imitation is the sincerest form of flattery.” The honor of who (or what) I imitated goes to the London-based publisher that made me a job offer very early in my career—the The Economist.

I chose a color palette around Pantone 2028 C (orange) and its complement, Pantone 3551 C (blue)—which aren’t necessarily my favorite colors (but do accurately represent the vibrancy and excitement I have about the art & science of almost everything I’ve done in my career).

The product designer in me is happy with style guide choices. The MBA in me is thoroughly satisfied with the personal brand in-the-making (I’ve stuck with it, surprisingly). The data journalist in me is pleasantly surprised that everything came together for an effective data visualization. It has been a win-win-win.

palette_michaelmallari_r <- c(
    "#ffffff",
    "#eb3300",  # Primary - Pantone 2028 C
    "#00a6c8",  # Complement - Pantone 3551 C
    "#4cae04", "#9063cd",  # Triadic - Pantone 3501 C, 265 C
    "#0084d4", "#00af66",  # Split Complement - Pantone 2184 C, 3405 C
    "#ee3831", "#d76b00",  # Analogous - Pantone 3556 C, 2019 C
    "#ca3604", "#ff7f41",  # Monochromatic - Pantone 2349 C, 164 C
    
    "#1d252d", "#5b6770", "#c1c6c8",  # Pantone 433 C; Monochromatic - Pantone 431 C, 428 C
    
    "#d7d2cb", "#d9d9d6",  # Pantone Warm Gray 1 C, Cool Gray 1 C
    
    "#f1f0eb", "#d7e7f0",  # The Economist warm gray, blue gray
    
    "#00587c", "#00a6c8", "#3ccbda"  # Pantone 3551 C (middle); Monochromatic - Pantone 308 C (left), 2226 C (right)
)

theme_michaelmallari_r <- function(){
    font = "Open Sans"
    theme_minimal() %+replace%
    theme(
        plot.background = element_rect(fill=palette_michaelmallari_r[18], linewidth=0),
        plot.margin = margin(16, 16, 16, 16, "pt"),
        plot.title = element_text(
            family="Open Sans",
            face="bold",
            colour=palette_michaelmallari_r[12],
            size=14,
            hjust=0,
            margin=margin(0, 0, 4, 0, "pt")
        ),
        plot.subtitle = element_text(
            family="Open Sans",
            colour=palette_michaelmallari_r[12],
            size=12,
            hjust=0,
            margin=margin(0, 0, 24, 0, "pt")
        ),
        plot.caption = element_text(
            family="Open Sans",
            colour=palette_michaelmallari_r[13],
            size=8,
            hjust=0,
            margin=margin(16, 0, 0, 0, "pt")
        ),
        panel.grid.major.x = element_blank(),
        panel.grid.major.y = element_line(color=palette_michaelmallari_r[14], size=0.25, linetype="solid"),
        panel.grid.minor = element_blank(),
        axis.line.x.bottom = element_line(color=palette_michaelmallari_r[12], linewidth=0.75, linetype="solid"),
        legend.position = "top"
    )
}

Distribution

Histogram

distribution_histogram_r <- ggplot2::ggplot(tiktok_songs_clean_r, aes(y=major_key)) +  # Data, aesthetics
    geom_histogram(stat="count", colour=palette_michaelmallari_r[19], fill=palette_michaelmallari_r[19]) +  # Geometric object, statistics
    geom_text(
        aes(label=..count..),
        stat="count",
        hjust=1.5,
        colour=palette_michaelmallari_r[1]
    ) +
    scale_y_discrete(limits=rev(levels(tiktok_songs_clean_r$major_key)), expand=c(0, 0), position="right") +  # Scale
    labs(
        title="Dependable Major Key of G and D (and Drop-Tuned C#/Db)",
        alt="Dependable Major Key of G and D (and Drop-Tuned C#/Db)",
        subtitle="Count of keys used on tracks (on TikTok videos), n = 223",
        x=NULL,
        y=NULL,
        caption="Source: https://www.kaggle.com/datasets/sveta151/tiktok-popular-songs-2019"
    ) +
    theme_michaelmallari_r()

distribution_histogram_r

Pyramid Chart

Box-and-Whisker Plot (or Boxplot or Schematic Plot)

distribution_box_and_whisker_plot_r <- ggplot2::ggplot(
        tiktok_songs_clean_r,  # Data
        aes(x=key, y=track_pop)  # Aesthetics
    ) +
    geom_boxplot(color=palette_michaelmallari_r[19], fill=palette_michaelmallari_r[20]) +  # Geometric object
    scale_y_continuous(expand=c(0, 0), position="right") +  # Scale
    labs(
        title="Key to Pop Songs on TikTok",
        alt="Key to Pop Songs on TikTok",
        subtitle="Keys that tend to make-up more pop songs than other genre, n = 223",
        x=NULL,
        y="Track's Pop Sensibilities",
        caption="Source: https://www.kaggle.com/datasets/sveta151/tiktok-popular-songs-2019"
    ) +
    theme_michaelmallari_r()

distribution_box_and_whisker_plot_r

Violin Chart

distribution_violin_chart_r <- ggplot2::ggplot(
        tiktok_songs_clean_r,
        aes(x=key, y=tempo)
    ) +
    geom_violin() +
    scale_y_continuous(expand=c(0, 0), position="right") +  # Scale
    labs(
        title="Pick-Up the Tempo on TikTok",
        alt="Pick-Up the Tempo on TikTok",
        subtitle="Keys that tend to be more up-tempo songs, n = 223",
        x=NULL,
        y="Tempo",
        caption="Source: https://www.kaggle.com/datasets/sveta151/tiktok-popular-songs-2019"
    ) +
    theme_michaelmallari_r()

distribution_violin_chart_r

Ridgeline Plot

distribution_ridgeline_plot_r <- ggplot2::ggplot(tiktok_songs_clean_r, aes(x=artist_pop, y=key, color=mode, fill=mode)) +  # Data, aesthetics
    ggridges::geom_density_ridges2(alpha=0.3, scale=1) +  # Geometric object
    scale_y_discrete(limits=rev(levels(tiktok_songs_clean_r$key)), expand=c(0, 0), position="right") +  # Scale
    scale_color_manual(values=c(palette_michaelmallari_r[2], palette_michaelmallari_r[19])) +
    scale_fill_manual(values=c(palette_michaelmallari_r[2], palette_michaelmallari_r[19])) +
    guides(color=guide_legend(reverse=TRUE), fill=guide_legend(reverse=TRUE)) +
    labs(
        title="Songs on TikTok From Pop Artists Using Major Key",
        alt="Songs on TikTok From Pop Artists Using Major Key",
        subtitle="Artists dependent on proven major keys for pop sensibilities, n = 223",
        x="Artist's Pop Sensibilities",
        y=NULL,
        color=NULL,
        fill=NULL,
        caption="Source: https://www.kaggle.com/datasets/sveta151/tiktok-popular-songs-2019"
    ) +
    theme_michaelmallari_r() +
    theme(
        panel.grid.major.x = element_line(color=palette_michaelmallari_r[14], size=0.25, linetype="solid"),
        panel.grid.major.y = element_blank()
    )

distribution_ridgeline_plot_r

Comparing Categories

Stacked Bar

comparing_categories_stacked_bar_r <- ggplot2::ggplot(tiktok_songs_clean_r, aes(x=..count.., y=major_key, fill=mode)) +  # Data, aesthetics
    geom_bar(position="stack", stat="count") +  # Geometric object, statistics
    geom_text(
        aes(label=..count..),
        stat="count",
        position=position_stack(vjust=0.5),
        colour=palette_michaelmallari_r[1]
    ) +
    scale_y_discrete(limits=rev(levels(tiktok_songs_clean_r$major_key)), expand=c(0, 0), position="right") +  # Scale
    scale_fill_manual(values=c(palette_michaelmallari_r[20], palette_michaelmallari_r[19])) +
    guides(fill=guide_legend(reverse=TRUE)) +
    labs(
        title="Majority Rules!",
        alt="Majority Rules!",
        subtitle="Frequency of major vs. minor keys on tracks (on TikTok videos), n = 223",
        x=NULL,
        y=NULL,
        fill="Mode on Track",
        caption="Source: https://www.kaggle.com/datasets/sveta151/tiktok-popular-songs-2019"
    ) +
    theme_michaelmallari_r()
    
comparing_categories_stacked_bar_r

Relationship

Scatterplot

relationship_scatterplot_r <- ggplot2::ggplot(tiktok_songs_clean_r, aes(x=artist_pop, y=speechiness)) +  # Data, aesthetics
    geom_point(color=palette_michaelmallari_r[19], alpha=0.3) +  # Geometric object
    geom_smooth(method=lm, colour=palette_michaelmallari_r[2]) +  # Geometric object
    scale_y_continuous(expand=c(0, 0), position="right") +  # Scale
    labs(
        title="TikTok Not a One-Trick Pony",
        alt="TikTok Not a One-Trick Pony",
        subtitle="Spreading its net wide by not focusing on killing two birds with one stone, n = 223",
        x="Danceability",
        y="Speechiness",
        caption="Source: https://www.kaggle.com/datasets/sveta151/tiktok-popular-songs-2019"
    ) +
    theme_michaelmallari_r()
    
relationship_scatterplot_r

Bubble Plot (or Bubble Scatterplot)

relationship_bubble_plot_r <- ggplot2::ggplot(tiktok_songs_clean_r, aes(x=loudness, y=energy)) +  # Data, aesthetics
    geom_point(aes(size=acousticness), color=palette_michaelmallari_r[19], alpha=0.3) +  # Geometric object, aesthetic
    geom_smooth(method=lm, colour=palette_michaelmallari_r[2]) +  # Geometric object
    scale_y_continuous(expand=c(0, 0), position="right") +  # Scale
    labs(
        title="Pump Up the Volume, Dance Dance on TikTok",
        alt="Pump Up the Volume, Dance Dance on TikTok",
        subtitle="Dance energy from song energy, and song energy from loudness, n = 223",
        x="Loudness",
        y="Energy",
        size="Acousticness",
        caption="Source: https://www.kaggle.com/datasets/sveta151/tiktok-popular-songs-2019"
    ) +
    theme_michaelmallari_r()
    
relationship_bubble_plot_r

Parallel Coordinates Plot

Radar Chart (or Spider Chart or Star Chart)

Chord Diagram

Arc Diagram

Correlation Matrix

correlation_pearson_r <- cor(
        subset(tiktok_songs_clean_r, select=-c(major_key, key, mode, artist_name, track_name, album)),
        method="pearson"
    ) %>%
    as.data.frame()
correlation_pearson_r
                 artist_pop track_pop duration_ms time_signature  tempo valence energy loudness instrumentalness acousticness liveness speechiness danceability
artist_pop            1.000     0.372       0.311         -0.106 -0.047  -0.080  0.149    0.306           -0.063       -0.051   -0.154      -0.359       -0.130
track_pop             0.372     1.000       0.188          0.022  0.033  -0.025  0.112    0.228           -0.090       -0.141   -0.035      -0.204       -0.128
duration_ms           0.311     0.188       1.000         -0.015 -0.096  -0.115  0.249    0.223           -0.193       -0.121   -0.129      -0.233       -0.071
time_signature       -0.106     0.022      -0.015          1.000 -0.092   0.095  0.108    0.088           -0.084       -0.054   -0.038       0.140        0.127
tempo                -0.047     0.033      -0.096         -0.092  1.000   0.059  0.131    0.092            0.088       -0.154   -0.112       0.036       -0.095
valence              -0.080    -0.025      -0.115          0.095  0.059   1.000  0.312    0.133            0.144        0.033    0.123      -0.090        0.102
energy                0.149     0.112       0.249          0.108  0.131   0.312  1.000    0.681           -0.173       -0.409    0.068      -0.117       -0.074
loudness              0.306     0.228       0.223          0.088  0.092   0.133  0.681    1.000           -0.350       -0.366   -0.032      -0.080        0.028
instrumentalness     -0.063    -0.090      -0.193         -0.084  0.088   0.144 -0.173   -0.350            1.000        0.268   -0.070      -0.139       -0.074
acousticness         -0.051    -0.141      -0.121         -0.054 -0.154   0.033 -0.409   -0.366            0.268        1.000   -0.023      -0.168       -0.255
liveness             -0.154    -0.035      -0.129         -0.038 -0.112   0.123  0.068   -0.032           -0.070       -0.023    1.000       0.004       -0.137
speechiness          -0.359    -0.204      -0.233          0.140  0.036  -0.090 -0.117   -0.080           -0.139       -0.168    0.004       1.000        0.368
danceability         -0.130    -0.128      -0.071          0.127 -0.095   0.102 -0.074    0.028           -0.074       -0.255   -0.137       0.368        1.000
correlation_pearson_r$var_1 <- rownames(correlation_pearson_r)

relationship_correlation_matrix_r <- correlation_pearson_r %>%
    tidyr::gather(key=var_2, value=r, 1:13) %>%
    ggplot(aes(x=var_1, y=var_2, fill=r)) +
        geom_tile() +
        geom_text(aes(label=round(r, 2)), size=2.2) +
        scale_y_discrete(position="right", limits=rev) +
        scale_fill_gradient2(limits=c(-1, 1), low=palette_michaelmallari_r[3], mid=palette_michaelmallari_r[1], high=palette_michaelmallari_r[2]) +
        labs(
            title="Starting a Dance Challenge on TikTok?",
            subtitle="Pearson correlation (r) to determine track's suitability for dancing, n = 223",
            x="",
            y="",
            fill="r",
            caption="Source: https://www.kaggle.com/datasets/sveta151/tiktok-popular-songs-2019"
        ) +
        theme_michaelmallari_r() +
        theme(
            axis.text.x=element_text(angle=90, hjust=1),
            plot.caption = element_text(margin=margin(8, 0, 0, 0, "pt")),
            legend.position = "right"
        )

relationship_correlation_matrix_r

Network Diagrams

Tree Diagrams


References

Applied Advanced Analytics & AI in Sports