top of page
Anexos
#Llamar los datos de Google Trends desde R-Studio
#install.packages("gtrendsR")
library(gtrendsR)
datos <- gtrends(keyword = c("cuarentena", "estudiantes", "depresion", "ansiedad", "estres"), geo = "MX", time = "today 12-m", gprop = "web", low_search_volume = FALSE, onlyInterest = FALSE)
#Llamar la Fecha, terminos, Frecuencia, busquedas en México, los ultimos 12 meses.
time_trend <- datos$interest_over_time head(time_trend)
#Graficos
library(ggplot2)
ggplot(data=time_trend) + aes(x=keyword, y=hits, color=keyword)+ geom_line()+ scale_colour_viridis_d(option = "viridis")+ geom_jitter(aes(color = keyword), size = 1, alpha = 0.7) + geom_boxplot(aes(color = keyword), alpha = 0.7) + labs(title = "Puntuaciones", x="Tiempo", y="Frecuencia", subtitle = "Datos de noviembre 2020 - noviembre 2021 ")+ theme_minimal()+ theme(legend.position="bottom")
#Linea de tiempo, últimos 12 meses.
ggplot(data=time_trend) + aes(x=date, y=hits, color=keyword)+ geom_line()+ scale_colour_viridis_d(option = "viridis")+ labs(title = "Puntuaciones", x="Tiempo", y="Frecuencia", subtitle = "Datos de noviembre 2020 - noviembre 2021 ")+ theme_minimal()+ theme(legend.position="bottom")
#Llamar datos de las busquedad en la entidad federativa... region_trend <- datos$interest_by_region head(region_trend)
ggplot(data = region_trend) + aes(x = location, fill = keyword, weight = hits) + geom_bar() + scale_fill_brewer(palette = "Set2") + labs(title = "Interes de los Estados de México", x = "Region", y = "Frecuencia", fill="Terminos", subtitle = "Datos generados en Google Trends ") + theme_minimal() + coord_flip()
bottom of page