A year of rostrum.blog

The hex sticker for rostrum.blog amended so that it says 'happy birthday' in pink Comic Sans and the insect design has a pink party hat on.

Happy first birthday 🎉

One year, visualised

There’s been 27 posts on rostrum.blog in its first year, so about one every two weeks.

This interactive graphic shows the publishing frequency, where each dot is a post and the x-axis is time. Turn your mobile to landscape mode to see it in full.

Expand for 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/")  # the site's homepage lists the posts

# 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") %>%  # element with the data we care about
  html_text() %>%  # convert to text
  str_replace_all("\n|[:space:]", "")  # replace newline-space with blank

# Dataframe of titles and dates
posts <- tibble(title = title, publish_date = date) %>% 
  mutate(publish_date = ymd(date)) %>%  # make column datetime
  arrange(publish_date) %>%  # order by date
  filter(publish_date < "2019-04-14")  # only posts before this one

# 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

# Object telling {plotly} not to do axes, etc 
ax <- list(
  title = "",
  zeroline = FALSE,
  showline = FALSE,
  showticklabels = FALSE,
  showgrid = FALSE
)

# Pass the plot object to plotly (actually performed outside this code chunk)
ggplotly(
  p,  # plot object
  tooltip = c("publish_date", "title")  # add mousover info
) %>%
  layout(xaxis = ax, yaxis = ax) %>%  # remove axes
  config(displayModeBar = FALSE)  # don't show plotly toolbar

More to come

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.2 (2018-12-20)
## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: macOS High Sierra 10.13.6
## 
## 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.1   backports_1.1.4   
##   base64enc_0.1.3    BH_1.69.0.1        blogdown_0.11     
##   bookdown_0.9       Cairo_1.5-10       cli_1.1.0         
##   colorspace_1.4-1   compiler_3.5.2     crayon_1.3.4      
##   crosstalk_1.0.1    curl_3.3           data.table_1.12.2 
##   digest_0.6.19      dplyr_0.8.1        emo_0.0.0.9000    
##   evaluate_0.14      fansi_0.4.0        ggplot2_3.1.1     
##   glue_1.3.1         graphics_3.5.2     grDevices_3.5.2   
##   grid_3.5.2         gtable_0.3.0       hexbin_1.27.2     
##   highr_0.8          htmltools_0.3.6    htmlwidgets_1.3   
##   httpuv_1.5.1       httr_1.4.0         jsonlite_1.6      
##   knitr_1.23         labeling_0.3       later_0.8.0       
##   lattice_0.20.38    lazyeval_0.2.2     lubridate_1.7.4   
##   magrittr_1.5       markdown_1.0       MASS_7.3.51.1     
##   Matrix_1.2.16      methods_3.5.2      mgcv_1.8.27       
##   mime_0.7           munsell_0.5.0      nlme_3.1.137      
##   openssl_1.4        pillar_1.4.1       pkgconfig_2.0.2   
##   plogr_0.2.0        plotly_4.9.0       plyr_1.8.4        
##   promises_1.0.1     purrr_0.3.2        R6_2.4.0          
##   RColorBrewer_1.1.2 Rcpp_1.0.2         reshape2_1.4.3    
##   rlang_0.4.0        rmarkdown_1.13     rstudioapi_0.10   
##   rvest_0.3.4        scales_1.0.0       selectr_0.4-1     
##   servr_0.13         shiny_1.3.2        sourcetools_0.1.7 
##   splines_3.5.2      stats_3.5.2        stringi_1.4.3     
##   stringr_1.4.0      sys_3.2            tibble_2.1.3      
##   tidyr_0.8.3        tidyselect_0.2.5   tinytex_0.13      
##   tools_3.5.2        utf8_1.1.4         utils_3.5.2       
##   vctrs_0.1.0        viridisLite_0.3.0  withr_2.1.2       
##   xfun_0.7           xml2_1.2.0         xtable_1.8-4      
##   yaml_2.2.0         zeallot_0.1.0