This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
paths <- list.dirs("posts", recursive = FALSE) | |
for (i in paths) { | |
from_dir <- i | |
date_rx <- "\\d{4}-\\d{2}-\\d{2}" | |
dates <- regexpr(date_rx, basename(i)) |> | |
regmatches(basename(i), m = _) |> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(ggthemes) | |
library(extrafont) | |
font_import() # might take a minute | |
loadfonts(device = "win") | |
df <- data.frame( | |
Time = 1:3, | |
Berthas = 2:0, | |
Sadness = 0:2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git log --oneline | |
git reset dc871db | |
git log --oneline | |
git reset --soft HEAD~; | |
git status | |
git rm posts/2020-05-16-postcode-pandemonium/Data/NSPL21_FEB_2023_UK.csv | |
git status | |
git add . | |
git commit -m "Fix back to 2020-05-16 postcodes, rename folder dates, correct punctuation post, rebuild site" | |
git push origin md-fix-latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Functions building on the {officer} package: | |
# https://davidgohel.github.io/officer/ | |
# You can read more about these functions in a blog post: | |
# https://www.rostrum.blog/2023/06/07/rectangular-officer/ | |
# There are other solutions. You can also try {docxtractr} by Bob Rudis | |
# (on CRAN), which doesn't depend on {officer}, or {officerExtras} by Eli | |
# Pousson (on GitHub). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`::`(dplyr, `%>%`)(mtcars, `::`(dplyr, select)(., cyl)) | |
# Challenge for the reader: isn't the bracket a function too...? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Extract and combine tables from multiple Word files | |
# This script creates some dummy docx files in temporary subfolders to mimic a | |
# user's filesystem. It then uses docxtractr::read_docx() to extract all the | |
# tables, and combines them with rbind(). | |
# A follow-up to my blogpost: | |
# https://www.rostrum.blog/2023/06/07/rectangular-officer/ | |
# Attach packages (all are available from CRAN) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Basic use of the {officer} package to scrape a table from a Word doc | |
# https://davidgohel.github.io/officer/ | |
# I've now written a couple of functions to do this task: | |
# https://gist.github.com/matt-dray/d4837f106bcee80ea39235b6465a7cac | |
# You can read more about those in a blog post: | |
# https://www.rostrum.blog/2023/06/07/rectangular-officer/ | |
# There are other solutions. You can also try {docxtractr} by Bon Rudis | |
# (on CRAN), which doesn't depend on {officer}, or {officerExtras} by Eli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example of an {a11ytables} xlsx output that has two tables | |
# 2023-04-25 | |
# {a11ytables} v0.1.0 | |
# Prepare cover table | |
cover_df <- tibble::tribble( | |
~subsection_title, ~subsection_content, | |
"Purpose", "Example results for something.", | |
"Workbook properties", "Some placeholder information.", | |
"Contact", "Placeholder email" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From the Analysis Function's guidance on charts: 'When an axis shows | |
# categorical data, you do not necessarily need tick marks, but if you do use | |
# them labels should be aligned between them.' Is this actually possible in | |
# ggplot2? A quick example. | |
# | |
# Link to guidance: | |
# https://analysisfunction.civilservice.gov.uk/policy-store/data-visualisation-charts/#section-3:~:text=on%20the%20chart.-,Tick%20marks,-Tick%20marks%20are | |
library(ggplot2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rvest) | |
library(polite) | |
library(tidyr) | |
site <- "https://gamewith.net/" | |
obsidian_page <- paste0(site, "pokemon-legends-arceus/article/show/31334") | |
css_table <- ".pokela_poke td" | |
bow_site <- bow(site, "M Dray <https://www.matt-dray.com/>") |