Skip to content

Commit 964f257

Browse files
committed
Hopeful fixes for Rmd vignette travis bugs, part deux
1 parent c753141 commit 964f257

File tree

2 files changed

+50
-5
lines changed

2 files changed

+50
-5
lines changed

vignettes/comics_gender.Rmd

+45
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,58 @@ This vignette is based on [538 study : Comic Books Are Still Made By Men, For Me
1818
library(fivethirtyeight)
1919
library(ggplot2)
2020
library(dplyr)
21+
library(readr)
22+
library(tidyr)
23+
library(lubridate)
24+
library(janitor)
2125
library(knitr)
2226
library(grid)
2327
library(fmsb)
2428
library(wordcloud)
2529
library(gridExtra)
2630
```
2731

32+
33+
#### Overview plots
34+
35+
Load full dataset using code in `?comic_characters` help file. Note we need to do this since `fivethirtyeight::comic_characters` only contains a
36+
preview of the first 10 rows of the full dataset.
37+
38+
```{r, warning = FALSE, message = FALSE}
39+
# Get DC characters:
40+
comic_characters_dc <-
41+
"https://github.com/fivethirtyeight/data/raw/master/comic-characters/dc-wikia-data.csv" %>%
42+
read_csv() %>%
43+
clean_names() %>%
44+
mutate(publisher = "DC")
45+
46+
# Get Marvel characters:
47+
comic_characters_marvel <-
48+
"https://github.com/fivethirtyeight/data/raw/master/comic-characters/marvel-wikia-data.csv" %>%
49+
read_csv() %>%
50+
clean_names() %>%
51+
mutate(publisher = "Marvel")
52+
53+
# Merge two dataset and perform further data wrangling:
54+
comic_characters <-
55+
comic_characters_dc %>%
56+
bind_rows(comic_characters_marvel) %>%
57+
separate(first_appearance, c("year2", "month"), ", ", remove = FALSE) %>%
58+
mutate(
59+
# If month was missing, set as January and day as 01:
60+
month = ifelse(is.na(month), "01", month),
61+
day = "01",
62+
# Note some years missing:
63+
date = ymd(paste(year, month, day, sep = "-")),
64+
align = factor(
65+
align,
66+
levels = c("Bad Characters", "Reformed Criminals", "Netural Characters", "Good Characters"),
67+
ordered = TRUE)
68+
) %>%
69+
select(publisher, everything(), -c(year2, day))
70+
```
71+
72+
2873
#### Overview plots
2974

3075
* percentage of Gender per publisher.

vignettes/trump_twitter.Rmd

+5-5
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ plotSentByTime <- function(trump_tweet_times, timeGroupVar) {
145145
timeVarLabel <- str_to_title(timeVar)
146146
147147
trump_tweet_time_sent <- trump_tweet_times %>%
148-
rename_(timeGroup = timeVar) %>%
148+
rename(timeGroup = !! timeVar) %>%
149149
group_by(timeGroup) %>%
150-
summarise(score = mean(score, na.rm=TRUE),Count = n()) %>%
150+
summarise(score = mean(score, na.rm=TRUE), Count = n()) %>%
151151
ungroup()
152152
153153
ggplot(trump_tweet_time_sent, aes(x=timeGroup, y=Count, fill = score)) +
@@ -159,22 +159,22 @@ plotSentByTime <- function(trump_tweet_times, timeGroupVar) {
159159

160160

161161
```{r plot_hour, fig.width=7, warning=FALSE}
162-
plotSentByTime(trump_tweet_times, hour)
162+
plotSentByTime(trump_tweet_times, "hour")
163163
```
164164

165165
* Trump tweets the least between 4 and 10 am.
166166
* Trump's tweets are most positive during the 10am hour.
167167

168168

169169
```{r plot_weekday, fig.width=7, warning=FALSE}
170-
plotSentByTime(trump_tweet_times, weekday)
170+
plotSentByTime(trump_tweet_times, "weekday")
171171
```
172172

173173
* Trump tweeted the most on Tuesday and Wednesday
174174
* Trump was most positive in the second part of the work week (Wed, Thurs, Fri)
175175

176176
```{r plot_month, fig.width=7, warning=FALSE}
177-
plotSentByTime(trump_tweet_times, month_over_time)
177+
plotSentByTime(trump_tweet_times, "month_over_time")
178178
```
179179

180180
* In this dataset, the number of tweets decreased after November 2015 and drastically dropped off after March 2016. It is unclear if this is a result of actual decrease in tweeting frequency or a result of the data collection process.

0 commit comments

Comments
 (0)