mm <- read.csv("file:///C:/Users/s-das/Syncplicity Folders/MyProjects_IMP/MY_Papers_V2/TRB 2020/00000000 FINALz/0010 nlp Twitter VisionZero/visionzero06192019_16191.csv")
mm
## text
## 1 RT @jen_keesmaat: Cities that are safe for everyone, have *literally* been redesigned to be safe, particularly for pedestrians and cyclists…
## 2 RT @MetCycleCops: Please be aware that Mechanically Propelled Scooters are illegal and can’t be used on roads. If you know someone that use…
## 3 RT @Dale_Bracewell: “After analyzing traffic crash data over a 13-year period... having a protected bike facility in a city would result in…
## 4 RT @cityoftoronto: At a red light, bikes should stop inside the green bike box and cars should stop behind it. Bicycles go first when traff…
## screenName retweetCount
## 1 darweesh821 418
## 2 MPSHammFul 193
## 3 geeemmpee 141
## 4 hexturtle 133
## [1] "text" "screenName" "retweetCount"
## Warning: package 'tidytext' was built under R version 3.5.3
# plot points labelled with tweet text
plot_tweets <- function(.df, y) {
y <- enquo(y)
.df %>%
mutate(text = str_wrap(text, 50)) %>%
ggplot(aes(x = fct_inorder(screenName), y = !!y)) +
geom_point(color = "#0172B1", size = 2) +
geom_label_repel(
aes(label = text),
size = 4,
force = 4,
nudge_y = 3,
point.padding = .5
) +
theme_minimal(14)
}
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.5.3
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
## Warning: package 'ggrepel' was built under R version 3.5.3
## Loading required package: ggplot2
library(stringr)
library(forcats)
mm %>%
arrange(desc(retweetCount)) %>%
plot_tweets(retweetCount) +
labs(x = "twitter user", y = "n retweets")+theme_bw(base_size = 16)
