Skip to content

Instantly share code, notes, and snippets.

View ryantimpe's full-sized avatar

Ryan Timpe ryantimpe

View GitHub Profile
@ryantimpe
ryantimpe / recthurs.R
Created August 27, 2021 18:41
rectthurs_20210826
#Recreation Thursday
# August 26, 2021
#https://twitter.com/kelsey_chalmers/status/1430875667793682432?s=20
library(tidyverse)
library(scales)
scale_dims = 10
scale_pattern = 1.5
@ryantimpe
ryantimpe / recthurs.R
Last active August 13, 2021 17:54
#RecreationThursday 2021-08-12
#Recreation Thursday
# August 12, 2021
library(tidyverse)
library(ggforce)
library(scales)
n_x = 13 #Number of circles along bottom X
n_y = 19 #Number of circles along side Y
@ryantimpe
ryantimpe / bricks_from_coords_custom.R
Created September 1, 2020 20:23
brickr::bricks_from_coords() with custom colors
#Only two big differences...
# Swap out brickr::lego_colors for lego_colors on line 57
# added brickr::: to collect_bricks() on line 89
bricks_from_coords_w_custom_colors <- function(coord_table,
use_bricks = NULL,
increment_level = 0, min_level = 1, max_level = Inf,
increment_x = 0, max_x = Inf,
increment_y = 0, max_y = Inf,
exclude_color = NULL, exclude_level = NULL){
@ryantimpe
ryantimpe / prime_factorization.R
Last active August 19, 2020 18:38
Reproduce color prime factorization chart
#Reproduce this prime factorization poster in R
#https://twitter.com/stevenstrogatz/status/1295915404574040065?s=20
library(tidyverse)
#Prime factorization function from SO
# https://stackoverflow.com/questions/49974601/r-prime-factorization
get_prime_factors = function(x){
n=c()
i=2
@ryantimpe
ryantimpe / cabinfever2.R
Created April 13, 2020 19:06
flametree & brickr
#Adapted from Jacqueline Nolis' project
# https://gist.github.com/jnolis/045403c4aa5e9b28e82d1c83b3dfe9ef
# remotes::install_github("djnavarro/flametree")
library(flametree)
library(brickr)
library(ggplot2)
library(png)
library(dplyr)
@ryantimpe
ryantimpe / brickr_0p3_releasevideo.R
Last active April 7, 2020 21:45
{brickr} 0.3 Release Video
# install.packages("brickr")
library(brickr)
library(rgl)
library(httr)
#Render static model ----
GET("http://www.ryantimpe.com/files/brickr_release3.xlsx",
write_disk(tf <- tempfile(fileext = ".xlsx")))
@ryantimpe
ryantimpe / babyyoda.R
Last active March 5, 2020 15:07
brickr_BabyYoda
library(dplyr)
library(brickr)
library(rgl)
library(httr)
#Render a static model
GET("http://www.ryantimpe.com/files/babyyoda.xlsx", write_disk(tf <- tempfile(fileext = ".xlsx")))
babyyoda <- readxl::read_xlsx(tf, sheet = "BabyYoda") %>%
bricks_from_excel()
@ryantimpe
ryantimpe / brickr_Ex3_RandomForest.R
Created March 22, 2019 13:32
{brickr} Example - Random Forest
library(tidyverse)
library(brickr)
display_colors()
random_tree <- function(xloc, yloc, height, radius){
startz <- round(height * (2/5))
#Build a 3x3 trunk
trunk_coords <- expand.grid( x = -1:1, y = -1:1,
@ryantimpe
ryantimpe / brickr_Ex2_Owl.R
Created March 15, 2019 21:12
{brickr} Example - Build an owl
library(brickr)
source(brickr_Owl_design.R)
#Remind me of the color names again...
display_colors()
#Use those names in the Color column
owl_colors <- tibble::tribble(
~.value, ~Color,
1, "Bright orange",
@ryantimpe
ryantimpe / brickr_Ex1.R
Created March 15, 2019 15:18
{brickr} Getting Started
library(brickr)
#This is a brick
brick <- data.frame(
Level="A",
X1 = rep(1,4),
X2 = rep(1,4)
)
brick %>%