Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryan Timpe ryantimpe

View GitHub Profile
@ryantimpe
ryantimpe / recthurs.R
Created Aug 27, 2021
rectthurs_20210826
View recthurs.R
#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 Aug 13, 2021
#RecreationThursday 2021-08-12
View recthurs.R
#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 Sep 1, 2020
brickr::bricks_from_coords() with custom colors
View bricks_from_coords_custom.R
#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 Aug 19, 2020
Reproduce color prime factorization chart
View prime_factorization.R
#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 Apr 13, 2020
flametree & brickr
View cabinfever2.R
#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 Apr 7, 2020
{brickr} 0.3 Release Video
View brickr_0p3_releasevideo.R
# 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 Mar 5, 2020
brickr_BabyYoda
View babyyoda.R
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 Mar 22, 2019
{brickr} Example - Random Forest
View brickr_Ex3_RandomForest.R
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 Mar 15, 2019
{brickr} Example - Build an owl
View brickr_Ex2_Owl.R
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 Mar 15, 2019
{brickr} Getting Started
View brickr_Ex1.R
library(brickr)
#This is a brick
brick <- data.frame(
Level="A",
X1 = rep(1,4),
X2 = rep(1,4)
)
brick %>%