Penggunaan Hashtag Tiktok
Tampilan Awal Website
Hasil Pencarian Rekomendasi Hashtag
rvest dan tidyverse sebagai cleaning tools
pada data yang telah diambil. Data yang telah discraping dari website
akan disimpan dalam MongoDB Atlas dan dijadwalkan setiap di jam 7.00
akan diambil secara acak lima hashtag yang berkaitan dengan 1 topik atau
jenis konten secara acak. Scraping terjadwal dilakukan dengan membuat
workflow di Github Action.
koleksi<-"tiktok_hashtag"
database<-"project_mds"
url_user<-"mongodb+srv://coba:risman1998@cluster1.rtjnft2.mongodb.net/?retryWrites=true&w=majority"#install.packages("mongolite")
library(mongolite)## Warning: package 'mongolite' was built under R version 4.2.3
atlas_tiktok <- mongo(
collection = koleksi,
db = database,
url = url_user
)atlas_tiktok$count()## [1] 25
atlas_tiktok$find('{}')atlas_tiktok$find(sort = '{"total_views": -1}', limit = 7)library(ggplot2)## Warning: package 'ggplot2' was built under R version 4.2.3
library(tidyverse)## Warning: package 'tidyverse' was built under R version 4.2.3
## Warning: package 'readr' was built under R version 4.2.3
## Warning: package 'stringr' was built under R version 4.2.3
## Warning: package 'forcats' was built under R version 4.2.3
## Warning: package 'lubridate' was built under R version 4.2.3
## -- Attaching core tidyverse packages ------------------------ tidyverse 2.0.0 --
## v dplyr 1.0.9 v readr 2.1.4
## v forcats 1.0.0 v stringr 1.5.0
## v lubridate 1.9.2 v tibble 3.1.8
## v purrr 0.3.4 v tidyr 1.2.0
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
## i Use the ]8;;http://conflicted.r-lib.org/conflicted package]8;; to force all conflicts to become errors
data_hashtag<-atlas_tiktok$find('{}')
head(data_hashtag)data2<-data_hashtag[order(data_hashtag$jumlah_video,decreasing = T),]
pl1 <- ggplot(data = data2[1:10,],aes(x= reorder(hashtag, jumlah_video), y = jumlah_video,fill = hashtag))
pl1 <- pl1 + geom_bar(stat = "identity")
pl1 <- pl1 + theme_classic() + scale_fill_viridis_d()
pl1 <- pl1 + theme(legend.position = "none")
pl1 <- pl1 + ggeasy::easy_rotate_labels(which = "x", angle = 90)
pl1 <- pl1 + labs(x = "Hashtag", y= "Jumlah Video")
pl1 <- pl1 + labs(title = "Jumlah Video berdasarkan Hashtag")
pl1pl1 <- ggplot(data = data2[1:10,],aes(x= reorder(hashtag, rata2_view_video), y = rata2_view_video,fill = hashtag))
pl1 <- pl1 + geom_bar(stat = "identity")
pl1 <- pl1 + theme_classic() + scale_fill_viridis_d()
pl1 <- pl1 + theme(legend.position = "none")
pl1 <- pl1 + ggeasy::easy_rotate_labels(which = "x", angle = 90)
pl1 <- pl1 + labs(x = "Hashtag", y= "Rata-rata View Video")
pl1 <- pl1 + labs(title = "Rata-rata View Video berdasarkan Hashtag")
pl1library(wordcloud)## Warning: package 'wordcloud' was built under R version 4.2.3
## Loading required package: RColorBrewer
set.seed(1234)
wordcloud(words = data_hashtag$hashtag, freq = data_hashtag$jumlah_video, min.freq = 1,max.words=200,random.order=FALSE, rot.per=0.35,colors=brewer.pal(8, "Dark2"))