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
# 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
# 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
# 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
filter(head(presidents), rep(1, 3)) # this uses utils::filter | |
#> Time Series: | |
#> Start = 1 | |
#> End = 6 | |
#> Frequency = 1 | |
#> [1] NA NA 244 220 188 NA | |
library(dplyr, warn.conflicts = FALSE) # attach dplyr | |
search() # shows dplyr will be preferred to utils if there's a nameclash |
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(openxlsx) | |
font_name <- "Comic Sans MS" | |
sheet_name <- "font_test" | |
font_null <- createStyle(fontName = font_name) | |
font_black <- createStyle(fontName = font_name, fontColour = "black") | |
font_red <- createStyle(fontName = font_name, fontColour = "red") | |
row_seq <- 1:nrow(beaver1) | |
wb_openxlsx <- createWorkbook() |
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
m <- matrix(rep(".", 30), 5, 6) | |
m[4, c(2:4, 6)] <- "X" | |
m[3, 2] <- "X" | |
m[5, 4:6] <- "X" | |
m[1, 4] <- "o" | |
matrix(1:140, 20, 7) | |
m <- pixeltrix::click_pixels(20, 7) | |
m[which(m == 0)] <- "." | |
m[which(m == 1)] <- "X" |
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
autoload -Uz vcs_info | |
precmd() { vcs_info } | |
zstyle ':vcs_info:git:*' formats '%b ' | |
setopt PROMPT_SUBST | |
PROMPT='%F{green}%*%f %F{blue}%~%f %F{red}${vcs_info_msg_0_}%f$ ' |
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
# @optajoe on Twitter: | |
# Stiliyan Petrov is the only player to have played in the Premier | |
# League whose name contains all the letters in the word 'Nativity'. | |
# Here: https://twitter.com/OptaJoe/status/1607028528289030144 | |
# Is that true? I decided to find out using my {soccercolleagues} | |
# package for R: https://www.rostrum.blog/2022/02/04/soccercolleagues/ | |
install_github("matt-dray/soccercolleagues") | |
library(soccercolleagues) |
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
png( | |
"~/Desktop/qr_test.png", | |
width = 5, | |
height = 5, | |
units = "cm", | |
res = 1200 | |
) | |
qrcode::qr_code("https://www.matt-dray.com") |> plot() |