5 min read

A year of rostrum.blog

Matt Dray (@mattdray)

Limited edition birthday sticker

Limited edition birthday sticker

rostrum.blog is a year old 🎉

This interactive graphic shows the publishing frequency.1 There’s been 27 posts, so about one every two weeks.

Code

# The data for the plot was scraped using {rvest} and visualised
# with {ggplot2} and {plotly}.

# Load packages
library(dplyr)  # data manipulation
library(rvest)  # web scrape
library(stringr)  # string manipulation
library(lubridate)  # deal with dates
library(ggplot2)  # plots
library(plotly)  # interactive plots

# Scrape the rostrum.blog home page
html <- read_html("https://rostrum.blog/")  # fro the frontpage

# Extract the post titles
title <- html %>%
  html_nodes(".archive-item-link") %>%  # node identified with SelectorGadget 
  html_text()  # extract the text from the node

# Extract the post dates
date <- html %>%
  html_nodes(".archive-item-date") %>%
  html_text() %>%
  str_replace_all("\n|[:space:]", "")

# Dataframe of titles and dates
posts <- tibble(title = title, publish_date = date) %>% 
  mutate(publish_date = ymd(date)) %>% 
  arrange(publish_date)

# Create plot object
p <- posts %>%
  mutate(count = 1) %>%   # dummy to indicate a post was made
  ggplot(aes(x = publish_date, y = count, label = title)) +
  geom_point(color = "#1D8016") +  # match the rostrum.blog green
  theme_void() +  # strip plot elements
  theme(panel.grid = element_blank())  # to stop plotly rendering grid

# Pass the plot object to plotly
ggplotly(
  p,  # plot object
  tooltip = c("publish_date", "title")  # mousover info
) %>%
  config(displayModeBar = F)  # don't show plotly toolsbar

You can continue to expect more posts about important topics like Pokemon, Dawson’s Creek, Kanye West, the National Basketball Association, Star Trek and dead deer.

I hope you’ve learnt something new about R, like how to begin using it, how to create reproducible reports, how to create interactive maps, how to build network graphs, how to webscrape, how to build simple serverless apps, how to debug tidyverse pipelines, or just remind yourself that you can do it.

Session info

## R version 3.5.3 (2019-03-11)
## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: macOS Mojave 10.14.1
## 
## Locale: en_GB.UTF-8 / en_GB.UTF-8 / en_GB.UTF-8 / C / en_GB.UTF-8 / en_GB.UTF-8
## 
## Package version:
##   askpass_1.1        assertthat_0.2.0   base64enc_0.1.3   
##   BH_1.69.0.1        blogdown_0.7       bookdown_0.7      
##   cli_1.0.1          colorspace_1.4-0   compiler_3.5.3    
##   crayon_1.3.4       crosstalk_1.0.0    curl_3.3          
##   data.table_1.11.8  digest_0.6.18      dplyr_0.8.0.1     
##   emo_0.0.0.9000     evaluate_0.13      fansi_0.4.0       
##   ggplot2_3.1.0      glue_1.3.0         graphics_3.5.3    
##   grDevices_3.5.3    grid_3.5.3         gtable_0.2.0      
##   hexbin_1.27.2      highr_0.7          htmltools_0.3.6   
##   htmlwidgets_1.3    httpuv_1.4.5.1     httr_1.4.0        
##   jsonlite_1.6       knitr_1.22         labeling_0.3      
##   later_0.8.0        lattice_0.20.38    lazyeval_0.2.1    
##   lubridate_1.7.4    magrittr_1.5       markdown_0.9      
##   MASS_7.3.51.1      Matrix_1.2.15      methods_3.5.3     
##   mgcv_1.8.27        mime_0.6           munsell_0.5.0     
##   nlme_3.1.137       openssl_1.2.2      pillar_1.3.1      
##   pkgconfig_2.0.2    plogr_0.2.0        plotly_4.8.0      
##   plyr_1.8.4         promises_1.0.1     purrr_0.3.1       
##   R6_2.4.0           RColorBrewer_1.1.2 Rcpp_1.0.0        
##   reshape2_1.4.3     rlang_0.3.1        rmarkdown_1.11    
##   rstudioapi_0.10    rvest_0.3.2        scales_1.0.0      
##   selectr_0.4-1      servr_0.10         shiny_1.2.0       
##   sourcetools_0.1.7  splines_3.5.3      stats_3.5.3       
##   stringi_1.3.1      stringr_1.4.0      sys_3.1           
##   tibble_2.0.1       tidyr_0.8.3        tidyselect_0.2.5  
##   tinytex_0.10       tools_3.5.3        utf8_1.1.4        
##   utils_3.5.3        viridisLite_0.3.0  withr_2.1.2       
##   xfun_0.5           xml2_1.2.0         xtable_1.8-3      
##   yaml_2.2.0


  1. Turn to landscape mode if you’re viewing on mobile so the graphic fits.