Analisando dados de mídias sociais em R
Sowmya Vivek
Data Science Coach

library(rtweet)
# Extrair 18000 tweets sobre "#politics"
pol <- search_tweets("#politics", n = 18000)
# Extrair dados de geolocalização e adicionar novas colunas
pol_coord <- lat_lng(pol)
coords_coords ou bbox_coordsView(pol_coord)

# Omitir linhas com valores ausentes de lat e lng
pol_geo <- na.omit(pol_coord[, c("lat", "lng")])
head(pol_geo)
lat lng
<dbl> <dbl>
19.17414 72.874244
53.35490 -6.247621
53.27350 -6.399521
53.67989 9.372680
12.92311 77.558448
54.59940 -5.836670
# Traçar longitude e latitude dos tweets no mapa dos EUA por estado
map(database = "state", fill = TRUE, col = "light yellow")
with(pol_geo, points(lng, lat, pch = 20, cex = 1, col = 'blue'))

# Traçar longitude e latitude dos tweets no mapa-múndi
map(database = "world", fill = TRUE, col = "light yellow")
with(pol_geo, points(lng, lat, pch = 20, cex = 1, col = 'blue'))

Analisando dados de mídias sociais em R