View perlin-dungeon-map-demo.R
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
print_perlin_dungeon <- function( | |
m, # matrix of perlin noise via ambient::noise_perlin() | |
invert = FALSE # flips tile positions (use set.seed before generating noise) | |
) { | |
tile_wall = "#" | |
tile_floor = "." | |
# Standardise noise values from 0 to 1 | |
m_bin <- round((m - min(m)) / (max(m) - min(m))) |
View edit-plus-code.R
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
# Use R's edit() function and generate code to reproduce it | |
# | |
# This is now being developed into the tide() function of the {tide} package: | |
# https://github.com/matt-dray/tide | |
# | |
# Original tweet: | |
# https://twitter.com/mattdray/status/1518374831993069570?s=20&t=L-xQ74slFk0UtlZ-nIs3Fg | |
# | |
# Question from @erdistats re edit + code creation: | |
# https://twitter.com/erdirstats/status/1518529179892994049 |
View rename-with-from-lookup.R
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(dplyr, warn.conflicts = FALSE) | |
x <- mtcars[1:5, 1:5] | |
x | |
#> mpg cyl disp hp drat | |
#> Mazda RX4 21.0 6 160 110 3.90 | |
#> Mazda RX4 Wag 21.0 6 160 110 3.90 | |
#> Datsun 710 22.8 4 108 93 3.85 | |
#> Hornet 4 Drive 21.4 6 258 110 3.08 |
View web-dissemination-a11ytables.R
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
# Web Dissemination Committee Q1 | |
# Matt Dray, March 2022 | |
# Packages ---------------------------------------------------------------- | |
# Install {a11ytables} from GitHub | |
install.packages(remotes) # if not yet installed | |
remotes::install_github("co-analysis/a11ytables") # v0.0.0.90012 at time of demo |
View mutate-if-any.R
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
# Goal: put 1 in new col where 1 appears across other cols | |
library(dplyr) | |
df <- tibble( | |
x1 = c(1, NA, NA), | |
x2 = c(NA, 1, NA), | |
x3 = c(NA, 1, NA) | |
) |
View link_walk_cycle.R
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
link_walk_cycle <- function(cycles = 5) { | |
link_v_top <- c( | |
0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0, | |
0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0, | |
0,0,2,0,1,3,3,3,3,3,3,1,0,2,0,0, | |
0,0,2,0,3,3,3,3,3,3,3,3,0,2,0,0, | |
0,0,2,2,3,2,1,2,2,1,2,3,2,2,0,0, | |
0,0,2,2,3,2,3,2,2,3,2,3,2,2,0,0, |
View eldrow.R
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
# I tweeted about this: | |
# https://twitter.com/mattdray/status/1481561924202553346 | |
# Then I blogged about it: | |
# https://www.rostrum.blog/2022/01/14/wordle/ | |
# remotes::install_github("coolbutuseless/wordle") | |
eldrow <- function(guess, answer, words = wordle::wordle_dict){ | |
answer <- tolower(answer) |
View twirdle.R
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
# I tweeted about this: | |
# https://twitter.com/mattdray/status/1481071849891057668?s=20 | |
# Then I blogged about it: | |
# https://www.rostrum.blog/2022/01/14/wordle/ | |
# Function to extract Wordle results from tweet data | |
twirdle <- function(tweets) { | |
g <- "\U1F7E9" | |
o <- "\U1F7E7" |
View gpx3d-extrude-colour.R
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
# Create a 3D ggplot with {ggrgl} and colour the extrusion by some variable | |
# | |
# Motivation via @geoff_tewierik: | |
# https://twitter.com/geoff_tewierik/status/1476662279437369346?s=20 | |
# See blog about the {gpx3d} package: | |
# https://www.rostrum.blog/2021/12/30/gpx3d/ | |
# See {gpx3d} package source: | |
# https://github.com/matt-dray/gpx3d | |
library(gpx3d) |
View acnh-tinder-analysis.R
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
# Blogpost: | |
# https://www.rostrum.blog/2020/06/06/acnh-swipe/ | |
# | |
# App: | |
# https://mattdray.shinyapps.io/acnh-swipe/ | |
x <- readr::read_csv("~/Desktop/acnh-swipe_results - Sheet1.csv") | |
x %>% | |
filter(swipe %in% c("left", "right"), name != "TEST") %>% |
NewerOlder