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
| library(tidyverse) | |
| library(transformr) | |
| library(tweenr) | |
| library(animation) | |
| # function to generate lissajous curves in a format | |
| # suitable for later tweening | |
| lissajous <- function(a=1, b=1, w=1, d=pi/2, t0=-pi, t1=pi, n=100) { | |
| tibble( | |
| t = seq(t0, t1, length.out = n), |
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
| library(showtext) | |
| library(fontr) | |
| library(tidyverse) | |
| library(transformr) | |
| library(animation) | |
| library(ggpolypath) | |
| # use showfont to load the font | |
| font_add_google("Allura") |
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
| # packages | |
| library(tidyverse) | |
| library(gganimate) | |
| library(gapminder) | |
| library(scales) | |
| # modified version of the bbc_style function | |
| # adapted from: https://github.com/bbc/bbplot | |
| bbc_style2 <- function(font = "Helvetica") { | |
| theme( |
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
| #devtools::install_github("djnavarro/asciify") | |
| library(asciify) | |
| library(magrittr) | |
| temporary <- function(file) { | |
| temp_dir <- tempfile() | |
| dir.create(temp_dir) | |
| file.path(temp_dir, file) | |
| } |
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
| library(geojsonio) | |
| library(here) | |
| library(broom) | |
| reload <- FALSE | |
| if(reload) { | |
| spdf <- geojson_read( | |
| x = here("unsw_map", "worldgeo.json"), | |
| what = "sp" | |
| ) |
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
| # operator that reverses the direction of assignment | |
| # only if called from the global environment | |
| `%>>%` <- function(x,y) { | |
| if(sys.nframe() == 1) { | |
| assign(deparse(substitute(y)), x, parent.frame()) | |
| } else { | |
| assign(deparse(substitute(x)), y, parent.frame()) | |
| } | |
| } |
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
| library(tidyverse) | |
| library(fontr) | |
| library(emojifont) | |
| library(ggpolypath) | |
| library(transformr) | |
| library(animation) | |
| library(Cairo) | |
| # create the base images from cat emoji and mouse emoji! | |
| cat <- glyph_polygon(ch = emoji("cat"), family = "EmojiOne") |
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
| library(ggplot2) | |
| library(dplyr) | |
| library(tibble) | |
| library(tidyr) | |
| GeomVector <- ggproto("GeomVector", Geom, | |
| required_aes = c("x", "y", "direction", "length"), | |
| default_aes = aes( |
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
| library(tidyverse) | |
| library(asciify) | |
| library(gganimate) | |
| p <- ascii_data("bayes.png") %>% | |
| ascii_map( | |
| alphabet = as.character(0:9), | |
| rescale = .15) %>% | |
| ascii_plot(charsize = 4) |
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
| # from section 7.5.1 of ggplot2 book | |
| library(ggplot2) | |
| base <- ggplot(diamonds, aes(carat, price)) + | |
| stat_bin2d() + | |
| geom_smooth(method = "lm") + | |
| xlab(NULL) + | |
| ylab(NULL) + | |
| theme(legend.position = "none") |