Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pos5737/tweets
A data set of Donald Trump's tweets for students to use to practice data wrangling.
https://github.com/pos5737/tweets
Last synced: 3 months ago
JSON representation
A data set of Donald Trump's tweets for students to use to practice data wrangling.
- Host: GitHub
- URL: https://github.com/pos5737/tweets
- Owner: pos5737
- Created: 2018-08-23T15:28:11.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-23T15:28:15.000Z (over 6 years ago)
- Last Synced: 2024-08-03T06:03:25.701Z (7 months ago)
- Language: R
- Size: 617 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
README
---
title: "README"
output: github_document
---```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, fig.path = "figs/")
```This repo contains data sets that students can use to practice wrangling data.
It contains:
* `trump-tweets.csv`: Donald Trump's last 3,200 tweets (as of 2019-08-23).
In order for the code that collects the data to work (i.e., `trump-tweets.R`), you must create a developer app and authenticate via access tokens. See Steps 1 and 2b from the rtweet [tutorial](https://rtweet.info).
```{r retweets-over-time, message=FALSE, warning=FALSE}
# load packages
library(tidyverse)
library(lubridate)# load data
df_raw <- read_csv("trump-tweets.csv")# wrangle data
df <- df_raw %>%
mutate(date = date(created_at),
retweets = retweet_count) %>%
select(date, retweets)
# plot data
ggplot(df, aes(x = date, y = retweets)) +
geom_point() +
scale_y_log10(breaks = scales::trans_breaks("log10", function(x) 10^x),
labels = scales::trans_format("log10", scales::math_format(10^.x))) +
annotation_logticks(sides = "l") +
geom_smooth() +
theme_bw() +
labs(x = "Date",
y = "Retweets",
title = "Number of Retweets Across Time")```