knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

R build status Coverage Status

This is an R interface to the SPLC hatetracker.io project.

The data goes back to August 2016.

Installation

Hatetracker is not on CRAN. Installation from GitHub is simplest via the devtools package:

devtools::install_github("davidski/hatetracker")

Thanks

Usage

Load the hatetracker library and some supporting tooling.

library(hatetracker)
library(tidyverse)
library(extrafont)

Fetch the trending hashtags used in the alt-right community for a specific day. The data is returned as a nested dataframe for each trending tag, including the total number of times menti. The nested time frame includes a z-score normalized trend for the number of mentions at 30 minute intervals throughout the requested date range.

charlottesville <- as.Date("2017-08-13")
dat <- get_hatetracker_activity(charlottesville + 1)
dat

Basic plotting of the activity.

dat %>% mutate(title = forcats::as_factor(title)) %>% 
  tidyr::unnest() %>% 
  ggplot(., aes(x = date, y = z_score)) + geom_col(fill = "orange") + 
  geom_hline(yintercept = 0) +
  #facet_wrap(~title, ncol = 1, strip.position = "left") +
  facet_grid(title ~ .) +
  hrbrthemes::theme_ipsum(grid = "") + 
  theme(strip.text.y = element_text(size = 12, angle = 0, hjust = 0)) +
  labs(title = "Top Hashtags Used by Alt-Right Twitter Accounts", 
       subtitle = "Day after the Charlottesville attack",
       caption = "Source: hatetracker.io",
       y = "Z-Score", x = NULL)

We can also look at historical mentions of specific tags. In this case, the #charlottesville tag.

historical <- get_hatetracker_activity2(charlottesville  - 7, charlottesville + 7)
char_hashtag <- historical[[1, "timeline"]]
char_hashtag
char_hashtag$attack <- as.Date(char_hashtag$date) == charlottesville
ggplot(char_hashtag, aes(date, z_score)) + 
  geom_col(aes(fill = attack)) +
  scale_fill_manual(values = c("orange", "red"), guide = FALSE) + 
  labs(x = NULL, y = "Z-Score", 
       title = "Use of Charlottesville Hashtag by Alt-Right Twitter Users", 
       subtitle = "Week preeceding and following the Chartlottsville attack",
       caption = "Source: hatetracker.io") +
  hrbrthemes::theme_ipsum(grid = "")

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

License

The MIT License applies.



davidski/hatetracker documentation built on Dec. 1, 2020, 5:24 p.m.