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
library(ggraph) | |
library(gganimate) | |
library(igraph) | |
# Data from http://konect.uni-koblenz.de/networks/sociopatterns-infectious | |
infect <- read.table('out.sociopatterns-infectious', skip = 2, sep = ' ', stringsAsFactors = FALSE) | |
infect$V3 <- NULL | |
names(infect) <- c('from', 'to', 'time') | |
infect$timebins <- as.numeric(cut(infect$time, breaks = 100)) | |
# We want that nice fading effect so we need to add extra data for the trailing |
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(tweenr) # Available on CRAN | |
library(ggforce) # Install from thomasp85/ggforce | |
library(gganimate) # Install from dgrtwo/gganimate | |
set.seed(2) | |
x <- sample(9,20, prob=c(1,2,3,4,5,4,3,2,1), replace=T) | |
df <- data.frame(x = x, y = 15) | |
dfs <- list(df) | |
for(i in seq_len(nrow(df))) { | |
dftemp <- tail(dfs, 1) | |
dftemp[[1]]$y[i] <- sum(dftemp[[1]]$x[seq_len(i)] == dftemp[[1]]$x[i]) |
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
library(magick) | |
library(reshape2) | |
library(dplyr) | |
library(tidygraph) | |
library(particles) | |
library(animation) | |
plot_fun <- function(sim) { | |
df <- as_tibble(sim) | |
plot(df$x, df$y, col = df$color, pch = '.', axes = FALSE, xlim = c(-100, 317), ylim = c(-268, 100), xlab = NA, ylab = NA) |
OlderNewer