Verifying that +thomasp85 is my blockchain ID. https://onename.com/thomasp85
This file contains 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('thomasp85/ggforce') | |
#devtools::install_github("dgrtwo/gganimate") | |
#devtools::install_github('thomasp85/ggraph') | |
#devtools::install_github("hadley/ggplot2") | |
library(ggraph) | |
library(ggforce) | |
library(gganimate) | |
library(ggplot2) | |
library(igraph) |
This file contains 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(ggforce) # need github version | |
library(tweenr) | |
library(animation) | |
# Define the different states | |
controls <- list( | |
data.frame( | |
x = runif(6), | |
y = runif(6), | |
col = 'steelblue', |
I hereby claim:
- I am thomasp85 on github.
- I am thomasp85 (https://keybase.io/thomasp85) on keybase.
- I have a public key ASDRGUror8ScAXuoC-MJVs06sOwPsdpyP9RU3GrLfkKU9Qo
To claim this, I am signing this object:
This file contains 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(future) | |
trim_model <- function(model, predictor = predict, ..., ignore_warnings = TRUE) { | |
# Cache the correct output | |
true_pred <- predictor(model, ...) | |
# Treat prediction warnings as errors? | |
if (!ignore_warnings) { | |
old_ops <- options(warn = 2) | |
on.exit(options(old_ops)) | |
} |
This file contains 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
--- | |
title: "R Notebook" | |
output: html_notebook | |
--- | |
# Difference in behavior between ggplot2 and patchwork plots in Notebooks | |
Consider the following ggplot | |
```{r} |
This file contains 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(tidygraph) | |
library(particles) | |
library(jsonlite) | |
library(magick) | |
# Prepare text polygons | |
text <- read_json('text.json') | |
par_text <- text$layers[[3]]$paths | |
on_text <- text$layers[[2]]$paths | |
cran_text <- text$layers[[1]]$paths |
This file contains 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
upper <- seq(0, pi, length.out = 181)[-181] | |
upper <-cbind(x = cos(upper), y = sin(upper)) | |
lower <- seq(pi, 2*pi, length.out = 181)[-181] | |
lower <- cbind(x = cos(lower), y = sin(lower)) | |
right <- seq(1.5*pi, 2.5*pi, length.out = 181)[-181] | |
right <- cbind(x = cos(right), y = sin(right)) | |
left <- seq(0.5*pi, 1.5*pi, length.out = 181)[-181] | |
left <- cbind(x = cos(left), y = sin(left)) | |
full <- cbind(x = cos(seq(0, 2*pi, length.out = 361)[-361]), | |
y = sin(seq(0, 2*pi, length.out = 361)[-361])) |
This file contains 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
st_close <- function(x) { | |
UseMethod('st_close') | |
} | |
st_close.sfg <- function(x) x | |
st_close.POLYGON <- function(x) { | |
if (st_is_empty(x)) return(x) | |
x[] <- lapply(x[], close_mat) | |
x[vapply(x[], nrow, integer(1)) > 3] | |
} | |
st_close.MULTIPOLYGON <- function(x) { |
This file contains 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(gganimate) | |
airq <- airquality | |
airq$Month <- format(ISOdate(2004,1:12,1),"%B")[airq$Month] | |
ggplot(airq, aes(Day, Temp, group = Month)) + | |
geom_line() + | |
geom_segment(aes(xend = 31, yend = Temp), linetype = 2, colour = 'grey') + | |
geom_point(size = 2) + | |
geom_text(aes(x = 31.1, label = Month), hjust = 0) + |
OlderNewer