This file contains hidden or 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
| require(picante) | |
| require(colorspace) | |
| #' Select colours from a palette to maximize perceptual distance between the colours | |
| #' | |
| #' This function takes a palette as a character vector of hexidecimal colours, and returns a smaller palette, | |
| #' attempting to maximize the mean perceptual distance (MPD) between the colours in the new palette. It uses CIELAB | |
| #' colorspace to map colour to a perceptually meaningful scale before maximizing distances | |
| #' | |
| #' @param pal A palette as a character vector containing hexidecimal coded colours | |
| #' @param sat.thresh Minimum saturation of colours in resulting palette (between 0 and 1) |
Is there an easy way to convert a named list into a dataframe, preserving the elements of the list in a "list-column"?
library(dplyr)
library(magrittr)
## make a random matrix
rand_mat <- function() {
Nrow <- sample(2:15,1)
Ncol <- sample(2:15,1)
This file contains hidden or 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
| ## Generate ALF simulations | |
| library(whisker) | |
| ALF_template <- function() { | |
| " webRequest := false; | |
| uuid := '4e4937bd-70e5-4caf-8521-f4340a4b7e09'; | |
| # name of simulation - you may want to change this | |
| mname := {{{simname}}}; | |
| # directories for file storage - you may want to change these |
This file contains hidden or 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
| player | Gender | hits | first | second | third | total | simple.points | image | image_ht | image_wd | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Kumail Nanjiani | M | 404000 | 4 | 2 | 0 | 6 | 0.833333333333333 | https://duckduckgo.com/i/b7d0c4ff.jpg | 200 | 164 | |
| Andy Daly | M | 182000 | 2 | 3 | 1 | 6 | 0.583333333333333 | https://duckduckgo.com/i/ff655da8.jpg | 200 | 133 | |
| Kyle Kinane | M | 190000 | 7 | 1 | 2 | 10 | 0.75 | https://duckduckgo.com/i/cb420bdf.jpg | 200 | 300 | |
| Kristen Schaal | F | 512000 | 2 | 1 | 1 | 4 | 0.625 | https://duckduckgo.com/i/0cf592c2.jpg | 200 | 150 | |
| Patton Oswalt | M | 747000 | 1 | 2 | 0 | 3 | 0.666666666666667 | https://duckduckgo.com/i/bbfa97b3.jpg | 200 | 168 | |
| Matt Besser | M | 167000 | 3 | 3 | 1 | 7 | 0.642857142857143 | https://duckduckgo.com/i/804ac973.jpg | 200 | 100 | |
| Moshe Kasher | M | 107000 | 5 | 3 | 1 | 9 | 0.722222222222222 | https://duckduckgo.com/i/122b4834.jpg | 200 | 200 | |
| Jonah Ray | M | 160000 | 3 | 5 | 2 | 10 | 0.55 | https://duckduckgo.com/i/09b947a3.jpg | 200 | 310 | |
| Ron Funches | M | 154000 | 11 | 2 | 0 | 13 | 0.923076923076923 | https://duckduckgo.com/i/d6db36c0.jpg | 200 | 143 |
This file contains hidden or 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
| player | Gender | hits | first | second | third | total | simple.points | image | image_ht | image_wd | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Kumail Nanjiani | M | 404000 | 4 | 2 | 0 | 6 | 0.833333333333333 | https://duckduckgo.com/i/b7d0c4ff.jpg | 200 | 164 | |
| Andy Daly | M | 182000 | 2 | 3 | 1 | 6 | 0.583333333333333 | https://duckduckgo.com/i/ff655da8.jpg | 200 | 133 | |
| Kyle Kinane | M | 190000 | 7 | 1 | 2 | 10 | 0.75 | https://duckduckgo.com/i/cb420bdf.jpg | 200 | 300 | |
| Kristen Schaal | F | 512000 | 2 | 1 | 1 | 4 | 0.625 | https://duckduckgo.com/i/0cf592c2.jpg | 200 | 150 | |
| Patton Oswalt | M | 747000 | 1 | 2 | 0 | 3 | 0.666666666666667 | https://duckduckgo.com/i/bbfa97b3.jpg | 200 | 168 | |
| Matt Besser | M | 167000 | 3 | 3 | 1 | 7 | 0.642857142857143 | https://duckduckgo.com/i/804ac973.jpg | 200 | 100 | |
| Moshe Kasher | M | 107000 | 5 | 3 | 1 | 9 | 0.722222222222222 | https://duckduckgo.com/i/122b4834.jpg | 200 | 200 | |
| Jonah Ray | M | 160000 | 3 | 5 | 2 | 10 | 0.55 | https://duckduckgo.com/i/09b947a3.jpg | 200 | 310 | |
| Ron Funches | M | 154000 | 11 | 2 | 0 | 13 | 0.923076923076923 | https://duckduckgo.com/i/d6db36c0.jpg | 200 | 143 |
This file contains hidden or 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
| Kumail Nanjiani | M | 404000 | 4 | 2 | 0 | 6 | 0.833333333333333 | https://duckduckgo.com/i/b7d0c4ff.jpg | 200 | 164 | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Andy Daly | M | 182000 | 2 | 3 | 1 | 6 | 0.583333333333333 | https://duckduckgo.com/i/ff655da8.jpg | 200 | 133 | |
| Kyle Kinane | M | 190000 | 7 | 1 | 2 | 10 | 0.75 | https://duckduckgo.com/i/cb420bdf.jpg | 200 | 300 | |
| Kristen Schaal | F | 512000 | 2 | 1 | 1 | 4 | 0.625 | https://duckduckgo.com/i/0cf592c2.jpg | 200 | 150 | |
| Patton Oswalt | M | 747000 | 1 | 2 | 0 | 3 | 0.666666666666667 | https://duckduckgo.com/i/bbfa97b3.jpg | 200 | 168 | |
| Matt Besser | M | 167000 | 3 | 3 | 1 | 7 | 0.642857142857143 | https://duckduckgo.com/i/804ac973.jpg | 200 | 100 | |
| Moshe Kasher | M | 107000 | 5 | 3 | 1 | 9 | 0.722222222222222 | https://duckduckgo.com/i/122b4834.jpg | 200 | 200 | |
| Jonah Ray | M | 160000 | 3 | 5 | 2 | 10 | 0.55 | https://duckduckgo.com/i/09b947a3.jpg | 200 | 310 | |
| Ron Funches | M | 154000 | 11 | 2 | 0 | 13 | 0.923076923076923 | https://duckduckgo.com/i/d6db36c0.jpg | 200 | 143 |
This file contains hidden or 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
| Kumail Nanjiani | M | 404000 | 4 | 2 | 0 | 6 | 0.833333333333333 | https://duckduckgo.com/i/b7d0c4ff.jpg | 200 | 164 | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Andy Daly | M | 182000 | 2 | 3 | 1 | 6 | 0.583333333333333 | https://duckduckgo.com/i/ff655da8.jpg | 200 | 133 | |
| Kyle Kinane | M | 190000 | 7 | 1 | 2 | 10 | 0.75 | https://duckduckgo.com/i/cb420bdf.jpg | 200 | 300 | |
| Kristen Schaal | F | 512000 | 2 | 1 | 1 | 4 | 0.625 | https://duckduckgo.com/i/0cf592c2.jpg | 200 | 150 | |
| Patton Oswalt | M | 747000 | 1 | 2 | 0 | 3 | 0.666666666666667 | https://duckduckgo.com/i/bbfa97b3.jpg | 200 | 168 | |
| Matt Besser | M | 167000 | 3 | 3 | 1 | 7 | 0.642857142857143 | https://duckduckgo.com/i/804ac973.jpg | 200 | 100 | |
| Moshe Kasher | M | 107000 | 5 | 3 | 1 | 9 | 0.722222222222222 | https://duckduckgo.com/i/122b4834.jpg | 200 | 200 | |
| Jonah Ray | M | 160000 | 3 | 5 | 2 | 10 | 0.55 | https://duckduckgo.com/i/09b947a3.jpg | 200 | 310 | |
| Ron Funches | M | 154000 | 11 | 2 | 0 | 13 | 0.923076923076923 | https://duckduckgo.com/i/d6db36c0.jpg | 200 | 143 |
This file contains hidden or 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
| ## This code makes this poster | |
| make_poster <- function() { | |
| library(ggplot2);library(imager);library(dplyr) | |
| library(tidyr); library(colorspace); library( | |
| sysfonts); library(showtext); if( !file.exists( | |
| "this_poster_is_made.png" ) ) { download.file( | |
| "https://www.r-project.org/logo/Rlogo.png", | |
| "Rlogo.png", mode = "wb"); font_add_google( | |
| "Finger Paint");R_logo<-load.image("Rlogo.png") | |
| ;poster_text <-capture.output(print(make_poster |
This document captures current best practices for R development, emphasizing modern tidyverse patterns, performance, and style. Last updated: August 2025
- Use modern tidyverse patterns - Prioritize dplyr 1.1+ features, native pipe, and current APIs
- Profile before optimizing - Use profvis and bench to identify real bottlenecks
- Write readable code first - Optimize only when necessary and after profiling
- Follow tidyverse style guide - Consistent naming, spacing, and structure
