We will analyze data from Spotify, an music app that allows people to play their favourite songs everywhere they go. We will read the data from top50.csv. The data has 50 observations with 14 variables and consists of songs which were on Top 50 Spotify Charts.
From the data named “songs”, songs genre and song title with the highest popularity and the total of their danceability are :
songs1 <- songs %>%
group_by(Track.Name,Genre) %>%
summarise(mean_popularity = mean(Popularity),
median_popularity = median(Popularity),
jumlah_danceability = sum(Danceability)) %>%
arrange(-mean_popularity)theme_algoritma <- theme(legend.key = element_rect(fill="black"),
legend.background = element_rect(color="white", fill="#263238"),
plot.subtitle = element_text(size=6, color="white"),
panel.background = element_rect(fill="#dddddd"),
panel.border = element_rect(fill=NA),
panel.grid.minor.x = element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_line(color="darkgrey", linetype=2),
panel.grid.minor.y = element_blank(),
plot.background = element_rect(fill="#263238"),
text = element_text(color="white"),
axis.text = element_text(color="white")
)library(ggplot2)
plot_songs <- ggplot(songs1, aes(x = Genre, y = mean_popularity)) +
geom_col(aes(fill = Genre), show.legend = FALSE)+
coord_flip()+
labs(title = "Mean Popularity on Each Genre",
x = "Genre",
y = "Popularity")+
theme_algoritma
plot_songsplot_songs3 <- ggplot(songs, aes(x = Artist.Name,
y = Popularity)) +
geom_boxplot(aes(x = Artist.Name, y = Popularity)) +
geom_smooth() +
labs(x = "Track Name",
y = "Popularity",
title = "Distribution plot Popularity") +
scale_color_brewer(palette = "Set3") +
theme(legend.position = "none") +
coord_flip()+
theme_algoritma
plot_songs3