Análisis del tópico Tara Reade
Tara Reade es una antigua empleada del candidato a la presidencia, Joe Biden. Durante el periodo de recogida de datos, Reade acuso publicamente al candidato de abusos sexuales en los 90. Se ha recogido información de twitter con este tópico para analizar la reacción de las comunidades
# librerias
library(qdapRegex)
library(sentimentr)
library(syuzhet)
library(lubridate)
library(tidyverse)
library(tidytext)
library(forcats)
library(tokenizers)
library(widyr)
library(igraph)
library(ggraph)
library(topicmodels)
library(forcats)
library(scales)
library(stringr)
library(extrafont)
library(reldist)
library(grid)
library(gridExtra)
library(boot)
library(ggradar)
library(tidygraph)
library(boot)
library(sp)
library(spData)
library(ggmap)
library(rgdal)
library(rgeos)
library(tmap)
# Sys.getenv()
Sys.setenv(JAVA_HOME = "C:\\Program Files\\Java\\jre1.8.0_251")
library(tm)
library(qdap)
# funciones auxiliares
source(here::here("scripts", "funciones_auxiliares.R"))
# paleta
plots_palette <- c("#ad5d51", "grey55", "#2b559e", "#947240")
# orden comunidades
comunidad_order <- c("GOP", "Independent", "DNC", "Progressives")
Estos datos han sido previamente procesados, sobre todo en lo que se refiere al texto de los tweets. Se excluyen términos relacionados con la pandemia que provoca la enfermedad COVID-19 (en el texto sin limpiar, hay un número amplio de términos para referirse a la enfermedad. Se han unificado todos en el término COVID19).
Se ha recogido también información sobre los seguidores de cuentas para definir 4 comunidades
# CARGA DE DATOS Y FORMATO ----------------------------------------------------------
library(tidyverse)
# carga y formato basico
tara <- readRDS(here::here("datos_procesados", "formated_text_df_data", "taradreade_no_sent.rds")) %>%
filter(str_detect(text, "#?covid19|#?COVID|#?[Pp]andemic|#trumpvirus", negate = T)) %>%
mutate(comunidad = fct_relevel(comunidad, c("GOP", "Independent", "DNC", "Progressives")),
user_id = as.character(user_id))
Como en los otros tópicos, una minoría de usuarios publica todos los tweets.
tara %>%
count(comunidad) %>%
mutate(f = percent(n/sum(n), accuracy = 0.1))
## # A tibble: 4 x 3
## comunidad n f
## <fct> <int> <chr>
## 1 GOP 36717 21.6%
## 2 Independent 98692 58.2%
## 3 DNC 18715 11.0%
## 4 Progressives 15557 9.2%
freq_tweets_usuario <- get_tweet_distribution(tara)
freq_tweets_usuario %>%
arrange(desc(tweets)) %>%
mutate(tweets_acum = cumsum(tweets),
usuarios_acum = cumsum(usuarios)) %>%
mutate(por_tweets_acum = tweets_acum / sum(tweets),
por_usuarios_acum = usuarios_acum / sum(usuarios)) %>%
mutate(int_users_acum = cut(por_usuarios_acum, breaks = seq(0, 1, by = 0.05))) %>%
group_by(comunidad, int_users_acum) %>%
summarise(porc_tweets = sum(porc_tweets)) %>%
mutate(porc_tweets_acum = cumsum(porc_tweets))
## # A tibble: 28 x 4
## # Groups: comunidad [4]
## comunidad int_users_acum porc_tweets porc_tweets_acum
## <fct> <fct> <dbl> <dbl>
## 1 GOP (0,0.05] 0.985 0.985
## 2 GOP (0.05,0.1] 0.0105 0.995
## 3 GOP (0.1,0.15] 0.00140 0.996
## 4 GOP (0.15,0.2] 0.00117 0.998
## 5 GOP (0.2,0.25] 0.000935 0.999
## 6 GOP (0.25,0.3] 0.000701 0.999
## 7 GOP (0.45,0.5] 0.000468 1.00
## 8 GOP (0.95,1] 0.000234 1
## 9 Independent (0,0.05] 0.994 0.994
## 10 Independent (0.05,0.1] 0.00353 0.997
## # ... with 18 more rows
# Curva de lorenz
freq_tweets_usuario %>%
ggplot(aes(x = porc_usuarios_acum, y = porc_tweets_acum)) +
geom_line(aes(color = comunidad), size = 1.3) +
scale_color_manual(values = plots_palette)
# gini
gini_comunidades <- freq_tweets_usuario %>%
group_by(comunidad) %>%
summarise(gini = gini(x = tweets, weights = porc_usuarios)) %>%
arrange(desc(gini))
Se intensifican los tópicos descubiertos en el gráfico anterior
tara_tfidf_mentions <- get_tfidf(tara_unigram %>% filter(str_detect(word, "^@"),comunidad!= "Independent") %>% get_frequencies())
plot_tfidf(tara_tfidf_mentions, cols = 3, colores = c(1, 3, 4)) +
labs(title = "Tópicos característicos de cada comunidad", y = "TF-IDF") +
guides(fill = F) +
theme(axis.title.x= element_blank(),
axis.text.y = element_text(size = 16),
legend.title = element_blank(),
strip.text = element_text(size = 15))
Todas las comunidades tienen una percepción negativa. No se hacen tests de diferencias en este caso
# limpeza de datos: se elimina trump y sanders
tara_for_sent <- tara %>%
filter(str_detect(text, "#?([Jj]oe|[Bb]iden|[Dd]onald|[Tt]rump|[Bb]ernie|[Ss]anders)", negate = T))
# adicion de sentimientos
sent_tara <- sentiment(tara_for_sent$text)
tara_for_sent$sent <- sent_tara$sentiment
tara_for_sent %>%
group_by(comunidad) %>%
summarise(sent = mean(sent))
## # A tibble: 3 x 2
## comunidad sent
## <fct> <dbl>
## 1 GOP -0.0622
## 2 DNC -0.0784
## 3 Progressives -0.0585
Percepción similar en las tres comunidades
nrc_tara <- tara_for_sent %>%
get_unigrams() %>%
filter(comunidad!= "Independent") %>%
inner_join(get_sentiments("nrc"), by = "word") %>%
filter(!sentiment %in% c("positive", "negative")) %>%
count(comunidad, sentiment, sort = T) %>%
mutate(sentiment = str_to_title(sentiment)) %>%
ungroup() %>%
group_by(comunidad) %>%
mutate(n = rescale(n)) %>%
pivot_wider(names_from = sentiment, values_from = n) %>%
select(comunidad, Joy, Trust, Fear, Surprise, Sadness, Disgust, Anger, Anticipation)
# predomina miedo
# el grafico se parece más entre Progresitas y Republicanos que entre demócratas y Republicanos
ggradar(nrc_tara %>% ungroup() %>% mutate(comunidad = fct_drop(comunidad)), group.colours = plots_palette[c(1, 3, 4)], legend.position = "top",
group.point.size = 4,
plot.title = "Sentimientos expresados hacia el tópico 'tara Change'", legend.text.size = 11) +
theme(plot.title = element_text(size = 12, family = "Georgia", color = "grey55"),
axis.title = element_text(family = "Georgia"))
Polarización significativa cuando se enfrenta al bando demócrata con los otros dos, pero es mayor en el caso de DNC-GOP.
# lectura datos test polaridad
pol_test_dif <- readRDS(here::here("datos_procesados", "formated_polarization_df_data", "polarization_testing", "TARA_polarization.rds"))
pol_test_dif[-1]
## $IC
## 2.5% 97.5%
## DNC-GOP 0.1693313 0.1859911
## DNC-PRG 0.1347827 0.1480397
##
## $resultado
## [1] "Diferencia significativa en medias"
# Nivel de polarizacion mínimo en ambos casos pero se hallan diferencias significativas
pol_test_dif$data %>%
ggplot(aes(x = sentimiento)) +
geom_histogram(aes(group = comunidad, fill = comunidad), color = "white", alpha = 0.5, binwidth = 0.002, position = "identity") +
scale_fill_manual(values = c(plots_palette[1], plots_palette[4])) +
labs(title = "Replicaciones bootstrap del scoring medio de polarización para los nodos frontera") +
theme_bw() + labs(x = "Average polarity score")