This repository has been archived by the owner on Aug 26, 2023. It is now read-only.
/
README.Rmd
119 lines (96 loc) · 5.01 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
```{r attach-pkgs, message=FALSE}
# Attach packages
suppressPackageStartupMessages({
library(dplyr)
library(stringr)
library(ggplot2)
library(rvest)
library(lubridate)
library(knitr)
library(emo)
})
```
```{r scrape-blog}
# Scrape the rostrum.blog home page
html <- read_html("https://rostrum.blog/")
# Extract the post titles
title <- html %>%
html_nodes(".archive-item-link") %>% # extract title node
html_text() # extract text
# Extract the post URLs
link <- html %>%
html_nodes(".archive-item-link") %>% # extract title node
html_attr("href") # extract href attribute
# Extract the post dates
date <- html %>%
html_nodes(".archive-item-date") %>% # extract date nodes only
html_text() %>% # extract text
str_replace_all("[:space:]", "") # remove newline/space
# Dataframe of titles and dates
posts <- tibble(date, title, link) %>%
transmute(
n = nrow(.):1, # number starting from first post
publish_date = ymd(date), # convert to date class
title, # title text
link = paste0("https://www.rostrum.blog", link) # create full URL
)
```
```{r plot-obj}
# Create plot object
p <- ggplot(posts) +
geom_point( # marker for today's date
aes(x = Sys.Date(), y = 1),
shape = "|", size = 10, stroke = 1, color = "grey95"
) +
geom_point( # markers for publishing dates
aes(x = publish_date, y = 1),
shape = "|", size = 10, stroke = 1, color = "#1D8016", alpha = 0.7
) +
theme(
legend.position = "none",
panel.grid = element_blank(),
axis.title = element_blank(),
axis.text.x = element_text(colour = "#1D8016"),
axis.text.y = element_blank(),
axis.ticks = element_blank(),
panel.background = element_blank()
)
```
<img src="https://raw.githubusercontent.com/matt-dray/stickers/master/output/rostrum_hex.png" alt="Hexagonal design containing the text 'rostrum.blog' and the blog's logo of a 16-bit insect." width="150" align="right">
# rostrum-blog
<!-- badges: start -->
[![rostrum.blog
post](https://img.shields.io/badge/rostrum-blog-008900?style=flat&labelColor=black&logo=data:image/gif;base64,R0lGODlhEAAQAPEAAAAAABWCBAAAAAAAACH5BAlkAAIAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAEAAQAAAC55QkISIiEoQQQgghRBBCiCAIgiAIgiAIQiAIgSAIgiAIQiAIgRAEQiAQBAQCgUAQEAQEgYAgIAgIBAKBQBAQCAKBQEAgCAgEAoFAIAgEBAKBIBAQCAQCgUAgEAgCgUBAICAgICAgIBAgEBAgEBAgEBAgECAgICAgECAQIBAQIBAgECAgICAgICAgECAQECAQICAgICAgICAgEBAgEBAgEBAgICAgICAgECAQIBAQIBAgECAgICAgIBAgECAQECAQIBAgICAgIBAgIBAgEBAgECAgECAgICAgICAgECAgECAgQIAAAQIKAAAh+QQJZAACACwAAAAAEAAQAAAC55QkIiESIoQQQgghhAhCBCEIgiAIgiAIQiAIgSAIgiAIQiAIgRAEQiAQBAQCgUAQEAQEgYAgIAgIBAKBQBAQCAKBQEAgCAgEAoFAIAgEBAKBIBAQCAQCgUAgEAgCgUBAICAgICAgIBAgEBAgEBAgEBAgECAgICAgECAQIBAQIBAgECAgICAgICAgECAQECAQICAgICAgICAgEBAgEBAgEBAgICAgICAgECAQIBAQIBAgECAgICAgIBAgECAQECAQIBAgICAgIBAgIBAgEBAgECAgECAgICAgICAgECAgECAgQIAAAQIKAAA7)](https://www.rostrum.blog/)
[![License: CC BY-NC-SA 4.0](https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg)](https://creativecommons.org/licenses/by-nc-sa/4.0/)
[![Netlify Status](https://api.netlify.com/api/v1/badges/ebfbdae4-a903-43e8-9f53-75becd95b42e/deploy-status)](https://app.netlify.com/sites/rostrum/deploys)
<!-- badges: end -->
Source files for [rostrum.blog](https://www.rostrum.blog/): fun and learning with the R language. Read more on the [about](https://www.rostrum.blog/about/) page.
Built with [{blogdown}](https://bookdown.org/yihui/blogdown/) and a customised [Lithium](https://github.com/jrutheiser/hugo-lithium-theme) theme. Deployed with [Netlify](https://www.netlify.com/).
# Stats
`r emo::ji("1234")` There have been `r nrow(posts)` posts on [the blog](https://www.rostrum.blog/) since `r min(posts$publish_date)`. `r if (format(today(), "%m-%d") == format(min(posts$publish_date), "%m-%d")) emo::ji("balloon")`
`r emo::ji("date")` That's a post roughly every `r round((as.numeric(today() - min(posts$publish_date))) / nrow(posts))` days, or about `r round(((nrow(posts) / (as.numeric(today() - min(posts$publish_date)))) * 30), 1)` posts per month.
`r emo::ji("new")` The latest post was published `r today() - max(posts$publish_date)` day(s) ago: [`r posts$title[1]`](`r posts$link[1]`).
`r emo::ji("chart_with_upwards_trend")` This 2D plot shows posts over time:
```{r plot-out, fig.height=1, fig.width=10, fig.alt="A 2D chart where each point represents a published blog post on a Y axis of time spanning from 2018 to the present. There are some gaps, but posts have been relatively consistent over time."}
p
```
<details><summary>`r emo::ji("open_file_folder")` Click to expand a full list of posts</summary>
```{r posts-table}
posts %>%
transmute(
Number = n,
Date = publish_date,
Title = paste0("[", title, "](", link, ")")
) %>%
kable()
```
</details>
---
_Updated on `r format(Sys.time(), "%Y-%m-%d at %H:%M")`._