Skip to content

Instantly share code, notes, and snippets.

@chichacha
chichacha / Daytime vs Nighttime.R
Created May 20, 2018 16:46
Figuring out what gist is...
library(tidyverse)
library(suncalc) ## https://CRAN.R-project.org/package=suncalc
library(scales) ## So I can use date_breaks etc on chart
library(lubridate) ## for dealing with time!
library(ggrepel)
interest <- c("dawn","sunrise","goldenHourEnd","goldenHour","sunset","dusk")
## dawn - sunrise - goldenHourEnd ==> Great time for photography in the morning.
@chichacha
chichacha / calendar_maker.r
Last active June 15, 2018 18:12
Calendar For Current Year (Monday as Start Date)
## 2018 Calendar
library(tidyverse)
library(hrbrthemes)
library(scales)
library(lubridate)
library(ggthemes)
## Set Global Option for Lubridate
options("lubridate.week.start"=1) ## 1 sets to Monday
@chichacha
chichacha / sample_spiral.r
Created December 1, 2018 05:21
Quick Viz with Soil Data using soilDB
library(soilDB)
library(tidyverse)
# load sample data from the soilDB package
data(loafercreek, package = "soilDB")
sample_set <- loafercreek@horizons %>% filter(!is.na(soil_color))
golden_angle <- pi*(3-sqrt(5))
library(tidyverse)
library(lubridate)
library(scales)
df <- tibble(
date = seq.Date(from=ymd("2019-01-01"),to=ymd("2019-12-31"),by="day"),
wkdy = wday(date,label=T),
mo = month(date,label=T),
mo.num = month(date,label=F),
day = day(date)
@chichacha
chichacha / 2019_4-4-5 Calendar.R
Created December 4, 2018 00:12
4-4-5 Calendar for 2019 - So I know which week is what. Monday as start date.
## Getting Ready for 2019
library(lubridate)
library(tibble)
options("lubridate.week.start"=1) ## 1 sets to Monday
calendar <- tibble(
date = seq.Date(from=ymd("2018-12-31"),to=ymd("2019-12-31"), by="day")
)
@chichacha
chichacha / Spirograph Inspired Art.rmd
Created December 11, 2018 06:25
Spirograph Inspired Art
---
title: "Spirograph Inspired Drawing"
output: html_notebook
editor_options:
chunk_output_type: console
---
Spirograph Inspired Drawing & Collaging Them Together.
@chichacha
chichacha / packingcircle_deldir.r
Created December 23, 2018 07:35
Circle Packing + Delaunay Triangulation
library(tidyverse)
library(deldir)
library(packcircles)
packing <- circleProgressiveLayout(x=runif(1000)) %>% mutate(id=row_number())
data_gg <- circleLayoutVertices(packing, npoints = 36) %>%
inner_join(packing %>% select(id,radius), by=c("id"))
dxy1 <- deldir(packing$x, packing$y)
@chichacha
chichacha / Colour Sorting using TSP.r
Last active December 27, 2018 07:27
Colour Bars with geom_tile
library(tidyverse)
library(imager)
library(TSP)
im <- load.image("https://static.highsnobiety.com/wp-content/uploads/2018/12/06095023/pantone-living-coral-color-2019-01-480x320.jpg")
im.df <- im %>%
imager::RGBtoHSV() %>%
as.data.frame(wide="c") %>%
@chichacha
chichacha / beeswarm.R
Created December 29, 2018 20:47
Simple Beeswarm Plot as Experiment
install.packages("beeswarm")
library(beeswarm)
library(tidyverse)
library(scales)
df <- tibble(
x = sample(x=c(2,6,17,24,25), size=3000, replace=T),
#x = sample(x=c(1,10,13,16,19,20,21), size=3000, replace=T),
y = rbeta(3000,2,5),
@chichacha
chichacha / DrawRandomFaces.R
Created December 30, 2018 06:57
Playing Around with Chernoff Face (aplpack package)
library(tidyverse)
library(aplpack)
draw_faces <- function(x=c(0,1,2,3,4,5),size=25, ncolors=10){
df <- tibble(
face_h = sample(x, size=size, replace=T),
face_w = sample(x, size=size, replace=T),
face_s = sample(x, size=size, replace=T),
mouth_h = sample(x, size=size, replace=T),
mouth_w = sample(x, size=size, replace=T),