All Projects → mkearney → cspan_data

mkearney / cspan_data

Licence: other
A repo for tracking the number of followers of Congress, the Cabinet, and Governors

Programming Languages

r
7636 projects
shell
77523 projects

Projects that are alternatives of or similar to cspan data

nicar tworkshop
Slides for #NICAR18 workshop on collecting and analyzing Twitter data
Stars: ✭ 23 (+43.75%)
Mutual labels:  twitter-api, rtweet, twitter-data
rtweet.download
{rtweet} helpers for automating large or time-consuming downloads
Stars: ✭ 24 (+50%)
Mutual labels:  twitter-api, rtweet, twitter-data
viewtweets
🙈🐵 View tweets (timelines, favorites, searches) in Rstudio 🐵🙈
Stars: ✭ 21 (+31.25%)
Mutual labels:  twitter-api, rtweet
trumptweets
Download data on all of Donald Trump's (@RealDonaldTrump) tweets
Stars: ✭ 39 (+143.75%)
Mutual labels:  twitter-api, mkearney-dataset
congresstweets
Datasets of the daily Twitter output of Congress.
Stars: ✭ 76 (+375%)
Mutual labels:  congress
gotwtr
gotwtr provides Twitter v2 API
Stars: ✭ 45 (+181.25%)
Mutual labels:  twitter-api
bitparrot
An app I created so developers can track the info they need: now includes Twitter API feeds and Machine Learning, Python, and Ruby on Rails sections.
Stars: ✭ 22 (+37.5%)
Mutual labels:  twitter-api
GraphiPy
GraphiPy: Universal Social Data Extractor
Stars: ✭ 61 (+281.25%)
Mutual labels:  twitter-api
twittered
Twitter API client for Java developers
Stars: ✭ 170 (+962.5%)
Mutual labels:  twitter-api
dtwitter
Script used in the DTwitter shortcut, currently available on RoutineHub
Stars: ✭ 26 (+62.5%)
Mutual labels:  twitter-api
us-house
117th United States House of Representatives - Contact Information, including: Phone Number, Mailing Address, Official Website, Twitter & Facebook Accounts.
Stars: ✭ 31 (+93.75%)
Mutual labels:  congress
twitter-most-followed-scripts
Scripts to find the most commonly followed Twitter accounts by a group of people
Stars: ✭ 25 (+56.25%)
Mutual labels:  twitter-api
labs-sample-code
Sample code for Twitter Developer Labs
Stars: ✭ 25 (+56.25%)
Mutual labels:  twitter-api
gotwi
A library for using the Twitter API v2 in the Go language. (It is still under development).
Stars: ✭ 32 (+100%)
Mutual labels:  twitter-api
shut-up-bird
🐦 Put your tweets/likes in an EPUB and delete them like a boss
Stars: ✭ 22 (+37.5%)
Mutual labels:  twitter-api
twauth-web
A simple Python Flask web app that demonstrates the flow of obtaining a Twitter user OAuth access token
Stars: ✭ 65 (+306.25%)
Mutual labels:  twitter-api
twitter-flood-generator
Simple Command Line Utility for Generating Twitter Floods
Stars: ✭ 61 (+281.25%)
Mutual labels:  twitter-api
Yatcobot
Yatcobot (Yet another twitter contest bot) is the most advanced and configurable bot for twitter contests and giveaways
Stars: ✭ 60 (+275%)
Mutual labels:  twitter-api
monkehTweets
A ColdFusion wrapper to interact with the Twitter API (with OAuth integration)
Stars: ✭ 52 (+225%)
Mutual labels:  twitter-api
Archive-Tweets
Archive and Delete Liked and Posted Tweets
Stars: ✭ 28 (+75%)
Mutual labels:  twitter-api

cspan_data

Tracking users-level data of (a) Members of Congress, (b) The Cabinet, and (c) Governors using CSPAN Twitter lists and the rtweet package.

#dataviz

Members of Congress

 

The Cabinet

 

Governors

 

Data collection script

Data collected using rtweet

## load rtweet and tidyverse
library(rtweet)

## define function for getting CSPAN Twitter lists data
get_cspan_list <- function(slug) {
  ## get users data of list members
  x <- lists_members(slug = slug, owner_user = "CSPAN")
  ## document slug
  x$cspan_list <- slug
  ## timestamp observations
  x$timestamp <- Sys.time()
  ## return data
  x
}

## cspan lists
cspan_lists <- c("members-of-congress", "the-cabinet", "governors")

## members of congress
cspan_data <- purrr::map(cspan_lists, get_cspan_list)

## merge into single data frame
cspan_data <- dplyr::bind_rows(cspan_data)

Data visualization script

Plots created using ggplot2 and ggrepel

## load tidyverse
suppressPackageStartupMessages(library(tidyverse))

## read all files
data_files <- list.files("data", full.names = TRUE)
cspan_data <- map(data_files, readRDS)

## merge into single data set
cspan_data <- bind_rows(cspan_data)

## shortcuts for subsetting into data sets
congress_data <- function(cspan_data) filter(
  cspan_data, cspan_list == "members-of-congress")
cabinet_data <- function(cspan_data) filter(
  cspan_data, cspan_list == "the-cabinet")
governors_data <- function(cspan_data) filter(
  cspan_data, cspan_list == "governors")

## plot most popular congress accounts
library(ggrepel)

## hacky function for labels
timestamp_range <- function(timestamp) {
  n <- length(unique(timestamp))
  x <- seq(min(timestamp), max(timestamp), length.out = (length(timestamp) / n))
  nas <- rep(as.POSIXct(NA_character_), length(x))
  c(x, rep(nas, n - 1L))
}

## member of congress
cspan_data %>%
  filter(followers_count > 3e5) %>%
  congress_data() %>%
  mutate(followers_count = log10(followers_count)) %>%
  arrange(timestamp) %>%
  mutate(x = timestamp_range(timestamp)) %>%
  group_by(screen_name) %>%
  mutate(mean = mean(followers_count)) %>%
  ungroup() %>%
  ggplot(aes(x = timestamp, y = followers_count, colour = screen_name, label = screen_name)) +
  theme_mwk(base_family = "Roboto Condensed") +
  theme(legend.position = "none") +
  geom_line() +
  geom_point() +
  geom_label_repel(aes(x = x, y = mean), family = "Roboto Condensed") +
  labs(title = "Tracking follower counts for members of Congress on Twitter",
    subtitle = "Tracking the number of Twitter followers of members of the Congress over time",
    x = NULL, y = "Number of followers (logged)",
    caption = "\nSource: Data collected via Twitter's REST API using rtweet (http://rtweet.info") +
  ggsave("plots/members-of-congress.png", width = 7, height = 9, units = "in")

## cabinet members
cspan_data %>%
  cabinet_data() %>%
  mutate(followers_count = log10(followers_count)) %>%
  arrange(timestamp) %>%
  mutate(x = timestamp_range(timestamp)) %>%
  group_by(screen_name) %>%
  mutate(mean = mean(followers_count)) %>%
  ungroup() %>%
  ggplot(aes(x = timestamp, y = followers_count, colour = screen_name, label = screen_name)) +
  theme_mwk(base_family = "Roboto Condensed") +
  theme(legend.position = "none") +
  geom_line() +
  geom_point() +
  geom_label_repel(aes(x = x, y = mean), family = "Roboto Condensed") +
  labs(title = "Tracking follower counts for Cabinet members on Twitter",
    subtitle = "Tracking the number of Twitter followers of members of the Cabinet over time",
    x = NULL, y = "Number of followers (logged)",
    caption = "\nSource: Data collected via Twitter's REST API using rtweet (http://rtweet.info") +
  ggsave("plots/the-cabinet.png", width = 7, height = 7, units = "in")

## governors
cspan_data %>%
  governors_data() %>%
  mutate(followers_count = log10(followers_count)) %>%
  arrange(timestamp) %>%
  mutate(x = timestamp_range(timestamp)) %>%
  group_by(screen_name) %>%
  mutate(mean = mean(followers_count)) %>%
  ungroup() %>%
  ggplot(aes(x = timestamp, y = followers_count, colour = screen_name, label = screen_name)) +
  theme_mwk(base_family = "Roboto Condensed") +
  theme(legend.position = "none") +
  geom_line() +
  geom_point() +
  geom_label_repel(aes(x = x, y = mean), family = "Roboto Condensed") +
  labs(title = "Tracking follower counts for U.S. Governors on Twitter",
    subtitle = "Tracking the number of Twitter followers of Governors over time",
    x = NULL, y = "Number of followers (logged)",
    caption = "\nSource: Data collected via Twitter's REST API using rtweet (http://rtweet.info)") +
  ggsave("plots/governors.png", width = 7, height = 9, units = "in")
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].