This R Notebook is the complement to my blog post The Decline of Imgur on Reddit and the Rise of Reddit’s Native Image Hosting.
This notebook is licensed under the MIT License. If you use the code or data visualization designs contained within this notebook, it would be greatly appreciated if proper attribution is given back to this notebook and/or myself. Thanks! :)
Setup
library(readr)
library(dplyr)
library(ggplot2)
library(scales)
library(bigrquery)
library(tidyr)
library(forcats)
sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.5
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] forcats_0.2.0 bindrcpp_0.2 tidyr_0.6.3 bigrquery_0.3.0.9000
[5] scales_0.4.1 ggplot2_2.2.1.9000 dplyr_0.7.0 readr_1.1.1
loaded via a namespace (and not attached):
[1] Rcpp_0.12.11 bindr_0.1 compiler_3.4.0 plyr_1.8.4
[5] prettyunits_1.0.2 base64enc_0.1-3 tools_3.4.0 progress_1.1.2
[9] digest_0.6.12 jsonlite_1.5 evaluate_0.10 tibble_1.3.3
[13] gtable_0.2.0 rlang_0.1.1 DBI_0.6-1 curl_2.6
[17] yaml_2.1.14 httr_1.2.1 stringr_1.2.0 knitr_1.16
[21] hms_0.3 rprojroot_1.2 grid_3.4.0 glue_1.1.0
[25] R6_2.2.2 rmarkdown_1.6 magrittr_1.5 backports_1.1.0
[29] htmltools_0.3.6 rsconnect_0.8 assertthat_0.2.0 colorspace_1.3-2
[33] httpuv_1.3.3 labeling_0.3 stringi_1.1.5 lazyeval_0.2.0
[37] openssl_0.9.6 munsell_0.4.3
theme_set(theme_minimal(base_size=9, base_family="Source Sans Pro") +
theme(plot.title = element_text(size=11, family="Source Sans Pro Bold"),
axis.title.x = element_text(family="Source Sans Pro Semibold"),
axis.title.y = element_text(family="Source Sans Pro Semibold"),
plot.caption = element_text(size=6, color="#CCCCCC")))
Include BigQuery Project name (NEVER share with anyone!)
Reddit is blue, Imgur is green.
Also, hard-code dates for vertical lines.
site_colors <- c(Reddit="#3498db", Imgur="#2ecc71")
reddit_image_beta_date <- as.numeric(as.Date('2016-05-24'))
reddit_image_sitewide_date <- as.numeric(as.Date('2016-06-21'))
Exploratory Reddit Data
Get Reddit submission data over time.
sql <- "
#standardSQL
SELECT DATE_TRUNC(DATE(TIMESTAMP_SECONDS(created_utc)), MONTH) as mon,
COUNT(*) as num_submissions,
COUNTIF(REGEXP_CONTAINS(domain, 'reddituploads.com|redd.it')) as num_reddit_image_submissions,
COUNTIF(REGEXP_CONTAINS(domain, 'imgur.com')) AS num_imgur_submissions
FROM `fh-bigquery.reddit_posts.*`
WHERE (_TABLE_SUFFIX BETWEEN '2016_01' AND '2017_04' OR _TABLE_SUFFIX = 'full_corpus_201512')
GROUP BY mon
ORDER BY mon
"
df_reddit_daily <- query_exec(sql, project = project, use_legacy_sql = FALSE)
Auto-refreshing stale OAuth token.
Running job -: 1s:
Running job \: 1s:
Running job |: 2s:
Running job /: 2s:
Running job -: 3s:
Running job \: 3s:
Running job |: 3s:
Running job /: 3s:
Running job -: 4s:
Running job \: 4s:
7.7 gigabytes processed
Running job |: 4s:
df_reddit_daily %>% tail()
plot <- ggplot(df_reddit_daily, aes(mon, num_submissions)) +
geom_line() +
scale_x_date() +
scale_y_continuous(labels = comma) +
labs(title = "Number of Submissions to Reddit, by Month",
x = "Month",
y = "# Submissions",
caption = "Max Woolf — minimaxir.com")
ggsave( "reddit-1.png", plot, width=5, height=3)
plot <- ggplot(df_reddit_daily, aes(mon, num_imgur_submissions)) +
geom_line(color=site_colors[2]) +
scale_x_date() +
scale_y_continuous(labels = comma) +
labs(title = "Number of Imgur Submissions to Reddit, by Month",
x = "Month",
y = "# Submissions",
caption = "Max Woolf — minimaxir.com")
ggsave( "reddit-2.png", plot, width=5, height=3)
Must reshape df with tidyr
to plot reddit + imgur on one plot:
df_reddit_daily_reshape <- df_reddit_daily %>%
gather(service, num_subs, num_imgur_submissions, num_reddit_image_submissions, factor_key=T) %>%
mutate(service = fct_recode(service, "Imgur" = "num_imgur_submissions", "Reddit" = "num_reddit_image_submissions"))
df_reddit_daily_reshape %>% head()
plot <- ggplot(df_reddit_daily_reshape, aes(mon, num_subs, color=service)) +
geom_line() +
scale_x_date() +
scale_y_continuous(labels = comma) +
scale_color_manual(values=site_colors, labels=c("Imgur Submissions", "Reddit-Hosted Image Submissions")) +
theme(legend.position="top", legend.margin=margin(t = -0.1, b = -0.25, unit='cm')) +
labs(title = "Imgur + Reddit-Hosted Image Submissions, by Month",
x = "Month",
y = "# Submissions",
caption = "Max Woolf — minimaxir.com",
color='')
ggsave("reddit-3.png", plot, width=5, height=3)
Market Share
sql <- "
#standardSQL
SELECT DATE_TRUNC(DATE(TIMESTAMP_SECONDS(created_utc)), day) as day,
COUNTIF(REGEXP_CONTAINS(domain, 'reddituploads.com|redd.it'))/COUNT(*) as Reddit,
COUNTIF(REGEXP_CONTAINS(domain, 'imgur.com')) /COUNT(*) as Imgur
FROM `fh-bigquery.reddit_posts.*`
WHERE (_TABLE_SUFFIX BETWEEN '2015_12' AND '2017_04')
GROUP BY day
ORDER BY day
"
df_reddit_perc_all <- query_exec(sql, project = project, use_legacy_sql = FALSE)
Running job -: 1s:
Running job \: 1s:
Running job |: 2s:
Running job /: 2s:
Running job -: 3s:
Running job \: 3s:
3.0 gigabytes processed
Running job |: 3s:
df_reddit_perc_all %>% tail()
df_reddit_perc_all_reshape <- df_reddit_perc_all %>%
gather(service, perc, Imgur, Reddit, factor_key=T)
df_reddit_perc_all_reshape %>% head()
plot <- ggplot(df_reddit_perc_all_reshape, aes(day, perc, color=service)) +
geom_vline(xintercept=reddit_image_beta_date, color="#e74c3c", linetype="dashed", size=0.25) +
geom_vline(xintercept=reddit_image_sitewide_date, color="#e67e22", linetype="dashed", size=0.25) +
geom_line(size = 0.5) +
scale_x_date(labels = date_format("%b %Y"), breaks=pretty_breaks(6)) +
scale_y_continuous(labels = percent) +
scale_color_manual(values=site_colors, labels=c("Imgur Submissions", "Reddit-Hosted Image Submissions")) +
theme(legend.position="top", legend.margin=margin(t = -0.1, b = -0.25, unit='cm')) +
labs(title = "Market Share of All Reddit Submissions",
x = "Day",
y = "% of All Submissions to Reddit",
caption = "Max Woolf — minimaxir.com",
color='')
ggsave("reddit-4.png", plot, width=4, height=3)
Look at only submissions in /r/pics and /r/gifs:
sql <- "
#standardSQL
SELECT DATE_TRUNC(DATE(TIMESTAMP_SECONDS(created_utc)), day) as day,
COUNTIF(REGEXP_CONTAINS(domain, 'reddituploads.com|redd.it'))/COUNT(*) as Reddit,
COUNTIF(REGEXP_CONTAINS(domain, 'imgur.com')) /COUNT(*) as Imgur
FROM `fh-bigquery.reddit_posts.*`
WHERE (_TABLE_SUFFIX BETWEEN '2015_12' AND '2017_04')
AND subreddit IN ('pics', 'gifs')
GROUP BY day
ORDER BY day
"
df_reddit_perc_pics <- query_exec(sql, project = project, use_legacy_sql = FALSE)
Running job -: 1s:
Running job \: 1s:
Running job |: 2s:
Running job /: 2s:
Running job -: 2s:
Running job \: 3s:
4.5 gigabytes processed
Running job |: 3s:
df_reddit_perc_pics_reshape <- df_reddit_perc_pics %>%
gather(service, perc, Imgur, Reddit, factor_key=T)
plot <- ggplot(df_reddit_perc_pics_reshape, aes(day, perc, color=service)) +
geom_vline(xintercept=reddit_image_beta_date, color="#e74c3c", linetype="dashed", size=0.25) +
geom_vline(xintercept=reddit_image_sitewide_date, color="#e67e22", linetype="dashed", size=0.25) +
geom_line(size = 0.5) +
scale_x_date(labels = date_format("%b %Y"), breaks=pretty_breaks(6)) +
scale_y_continuous(labels = percent) +
scale_color_manual(values=site_colors, labels=c("Imgur Submissions", "Reddit-Hosted Image Submissions")) +
theme(legend.position="top", legend.margin=margin(t = -0.1, b = -0.25, unit='cm')) +
labs(title = "Market Share of /r/pics and /r/gifs Submissions",
x = "Day",
y = "% of All Submissions to /r/pics + /r/gifs",
caption = "Max Woolf — minimaxir.com",
color='')
ggsave("reddit-5.png", plot, width=4, height=3)
Imgur Direct vs. Indirect
sql <- "
#standardSQL
SELECT DATE_TRUNC(DATE(TIMESTAMP_SECONDS(created_utc)), day) as day,
COUNTIF(domain = 'imgur.com' OR domain = 'm.imgur.com')/COUNTIF(REGEXP_CONTAINS(domain, 'imgur.com')) as Indirect,
COUNTIF(domain = 'i.imgur.com')/COUNTIF(REGEXP_CONTAINS(domain, 'imgur.com')) as Direct
FROM `fh-bigquery.reddit_posts.*`
WHERE (_TABLE_SUFFIX BETWEEN '2015_12' AND '2017_04')
GROUP BY day
ORDER BY day
"
df_imgur_direct <- query_exec(sql, project = project, use_legacy_sql = FALSE)
Running job -: 1s:
Running job \: 1s:
Running job |: 2s:
Running job /: 2s:
Running job -: 3s:
Running job \: 3s:
3.0 gigabytes processed
Running job |: 3s:
df_imgur_direct %>% tail()
df_imgur_direct_reshape <- df_imgur_direct %>%
gather(service, perc, Direct, Indirect, factor_key=T)
plot <- ggplot(df_imgur_direct_reshape, aes(day, perc, color=service)) +
geom_line(size = 0.5) +
scale_x_date(labels = date_format("%b %Y"), breaks=pretty_breaks(6)) +
scale_y_continuous(labels = percent) +
scale_color_hue(l=65, h.start = 10, labels=c("Direct Link to Image", "Indirect Link to Imgur Website")) +
theme(legend.position="top", legend.margin=margin(t = -0.1, b = -0.25, unit='cm')) +
labs(title = "Breakdown of Direct vs. Indirect Imgur Links",
x = "Day",
y = "% of All Imgur Submissions to Reddit",
caption = "Max Woolf — minimaxir.com",
color='')
ggsave("reddit-6.png", plot, width=4, height=3)
LICENSE
The MIT License (MIT)
Copyright (c) 2017 Max Woolf
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
LS0tCnRpdGxlOiAiVGhlIERlY2xpbmUgb2YgSW1ndXIgb24gUmVkZGl0IGFuZCB0aGUgUmlzZSBvZiBSZWRkaXQncyBOYXRpdmUgSW1hZ2UgSG9zdGluZyIKYXV0aG9yOiAiTWF4IFdvb2xmIChAbWluaW1heGlyKSIKZGF0ZTogIjIwMTctMDYtMjAiCm91dHB1dDoKICBodG1sX25vdGVib29rOgogICAgaGlnaGxpZ2h0OiB0YW5nbwogICAgbWF0aGpheDogbnVsbAogICAgbnVtYmVyX3NlY3Rpb25zOiB5ZXMKICAgIHRoZW1lOiBzcGFjZWxhYgogICAgdG9jOiB5ZXMKLS0tCgpUaGlzIFIgTm90ZWJvb2sgaXMgdGhlIGNvbXBsZW1lbnQgdG8gbXkgYmxvZyBwb3N0IFtUaGUgRGVjbGluZSBvZiBJbWd1ciBvbiBSZWRkaXQgYW5kIHRoZSBSaXNlIG9mIFJlZGRpdCdzIE5hdGl2ZSBJbWFnZSBIb3N0aW5nXShodHRwOi8vbWluaW1heGlyLmNvbS8yMDE3LzA2L2ltZ3VyLWRlY2xpbmUvKS4KClRoaXMgbm90ZWJvb2sgaXMgbGljZW5zZWQgdW5kZXIgdGhlIE1JVCBMaWNlbnNl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QlkgbW9uCiAgT1JERVIgQlkgbW9uCiIKCmRmX3JlZGRpdF9kYWlseSA8LSBxdWVyeV9leGVjKHNxbCwgcHJvamVjdCA9IHByb2plY3QsIHVzZV9sZWdhY3lfc3FsID0gRkFMU0UpCmBgYAoKYGBge3J9CmRmX3JlZGRpdF9kYWlseSAlPiUgdGFpbCgpCmBgYAoKYGBge3J9CnBsb3QgPC0gZ2dwbG90KGRmX3JlZGRpdF9kYWlseSwgYWVzKG1vbiwgbnVtX3N1Ym1pc3Npb25zKSkgKwogICAgICAgICAgZ2VvbV9saW5lKCkgKwogICAgICAgICAgc2NhbGVfeF9kYXRlKCkgKwogICAgICAgICAgc2NhbGVfeV9jb250aW51b3VzKGxhYmVscyA9IGNvbW1hKSArIAogICAgICAgICAgbGFicyh0aXRsZSA9ICJOdW1iZXIgb2YgU3VibWlzc2lvbnMgdG8gUmVkZGl0LCBieSBNb250aCIsCiAgICAgICAgICAgICAgIHggPSAiTW9udGgiLAogICAgICAgICAgICAgICB5ID0gIiMgU3VibWlzc2lvbnMiLAogICAgICAgICAgICAgICBjYXB0aW9uID0gIk1heCBXb29sZiDigJQgbWluaW1heGlyLmNvbSIpCgpnZ3NhdmUoICJyZWRkaXQtMS5wbmciLCBwbG90LCB3aWR0aD01LCBoZWlnaHQ9MykKYGBgCgohW10ocmVkZGl0LTEucG5nKQoKCmBgYHtyfQpwbG90IDwtIGdncGxvdChkZl9yZWRkaXRfZGFpbHksIGFlcyhtb24sIG51bV9pbWd1cl9zdWJtaXNzaW9ucykpICsKICAgICAgICAgIGdlb21fbGluZShjb2xvcj1zaXRlX2NvbG9yc1syXSkgKwogICAgICAgICAgc2NhbGVfeF9kYXRlKCkgKwogICAgICAgICAgc2NhbGVfeV9jb250aW51b3VzKGxhYmVscyA9IGNvbW1hKSArIAogICAgICAgICAgbGFicyh0aXRsZSA9ICJOdW1iZXIgb2YgSW1ndXIgU3VibWlzc2lvbnMgdG8gUmVkZGl0LCBieSBNb250aCIsCiAgIC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