spotify_track <- read.csv("spotify_tracks.csv")

head(df)
##                                               
## 1 function (x, df1, df2, ncp, log = FALSE)    
## 2 {                                           
## 3     if (missing(ncp))                       
## 4         .Call(C_df, x, df1, df2, log)       
## 5     else .Call(C_dnf, x, df1, df2, ncp, log)
## 6 }
library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
ggplot(spotify_track, aes(x = popularity)) + 
  geom_histogram(bins = 20, fill = "steelblue") + 
  theme_minimal() + 
  labs(title = "Distribusi Popularitas Lagu", 
       x = "Popularitas", 
       y = "Frekuensi")

ggplot(spotify_track, aes(x = duration_ms/60000)) + 
  geom_histogram(bins = 30, fill = "#1DB954", color = "white") + 
  theme_minimal() + 
  labs(title = "Distribusi Durasi Lagu", 
       x = "Durasi (menit)", 
       y = "Frekuensi")

spotify_track %>% 
  count(artists) %>% 
  top_n(10, n) %>% 
  ggplot(aes(x = reorder(artists, n), y = n, fill = n)) + 
  geom_col() + 
  coord_flip() + 
  scale_fill_gradient(low = "#3498DB", high = "#E74C3C") +
  theme_minimal() + 
  labs(title = "Top 10 Artis dengan Lagu Terbanyak", 
       x = "Artis", 
       y = "Jumlah Lagu") +
  theme(legend.position = "none")