# NOT RUN {
# To obtain the entire dataset, run the following code:
library(readr)
library(dplyr)
ratings <-
"https://github.com/fivethirtyeight/data/raw/master/inconvenient-sequel/ratings.csv" %>%
read_csv() %>%
mutate(category = as.factor(category)) %>%
rename(
votes_1 = `1_votes`, votes_2 = `2_votes`, votes_3 = `3_votes`,
votes_4 = `4_votes`, votes_5 = `5_votes`, votes_6 = `6_votes`,
votes_7 = `7_votes`, votes_8 = `8_votes`, votes_9 = `9_votes`,
votes_10 = `10_votes`,
pct_1 = `1_pct`, pct_2 = `2_pct`, pct_3 = `3_pct`, pct_4 = `4_pct`,
pct_5 = `5_pct`, pct_6 = `6_pct`, pct_7 = `7_pct`, pct_8 = `8_pct`,
pct_9 = `9_pct`, pct_10 = `10_pct`
)
# To convert data frame to tidy data (long) format, run:
library(dplyr)
library(tidyr)
library(stringr)
ratings_tidy <- ratings %>%
gather(votes, count, -c(timestamp, respondents, category, link, average, mean, median)) %>%
arrange(timestamp)
# }
Run the code above in your browser using DataLab