R ile Sosyal Medya Verilerini Analiz Etme
Vivek Vijayaraghavan
Data Science Coach





# galaxy fold hakkında tweetleri çıkar
twts_galxy <- search_tweets("galaxy fold", n = 5000,
lang = "en", include_rts = FALSE)
# galaxy fold tweetleri için duygu analizi yap
library(syuzhet)
sa.value <- get_nrc_sentiment(twts_galxy$text)
# Duygu puanlarını görüntüle
sa.value[1:5,1:7]
anger anticipation disgust fear joy sadness surprise
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
0 0 0 0 0 0 0
1 0 0 0 0 0 0
1 1 0 2 1 1 1
0 0 0 1 0 0 0
0 0 0 0 0 0 0
# Duygu puanlarının toplamını hesapla
score <- colSums(sa.value[,])
# Veri çerçevesine dönüştür
score_df <- data.frame(score)
# Veri çerçevesini görüntüle
score_df
score
<dbl>
anger 211
anticipation 825
disgust 214
fear 253
joy 412
sadness 197
surprise 315
trust 641
negative 487
positive 1351
# Satır adlarını 'sentiment' sütununa çevir
# Duygu puanlarıyla birleştir
sa.score <- cbind(sentiment = row.names(score_df),
score_df, row.names=NULL)
# Duygu puanlı veri çerçevesini görüntüle
print(sa.score)
sentiment score
<fct> <dbl>
anger 211
anticipation 825
disgust 214
fear 253
joy 412
sadness 197
surprise 315
trust 641
negative 487
positive 1351
ggplot() ile duygu puanlarını görselleştirin# Duygu puanlarını görselleştir
ggplot(data = sa.score2, aes(x = sentiment, y = score,
fill = sentiment)) +
geom_bar(stat = "identity") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))

R ile Sosyal Medya Verilerini Analiz Etme