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
# https://rstudio-pubs-static.s3.amazonaws.com/294422_099df24a1c0f46f99db848ca5c48ff6b.html | |
library(tidyverse) | |
plots <- mtcars %>% | |
group_by(cyl) %>% | |
nest() %>% | |
mutate(plot = map(data, ~ggplot(., aes(mpg, wt)) + geom_point()), | |
filename = paste0(cyl, ".pdf")) %>% | |
select(filename, plot) |
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
# Example of a geospatial union between polygons with R's {sf} package | |
# Combine East and West Midlands to 'Midlands' | |
# This example uses a GeoJSON of super-generalised clipped boundaries for England's regions: | |
# http://geoportal.statistics.gov.uk/datasets/regions-december-2017-super-generalised-clipped-boundaries-in-england | |
# (click the API dropdown on this page and copy the URL for the GeoJSON) | |
# Packages | |
library(geojsonio) | |
library(sf) |
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("sctyner/memer") | |
library(memer) | |
library(tidyverse) | |
library(magick) | |
memes <- tibble(meme_name = meme_list()) %>% | |
mutate( | |
image = map(meme_name, meme_get), | |
path = paste0(getwd(), "/", meme_name, ".jpg") | |
) %>% |
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: "googleVis test" | |
author: "Matt Dray" | |
date: "23/04/2019" | |
output: html_document | |
--- | |
Set up example dataframe from [the {googleVis} examples](https://cran.r-project.org/web/packages/googleVis/vignettes/googleVis_examples.html) CRAN vignette. | |
```{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
# Inspired by https://www.displayr.com/sankey-diagrams-r/ | |
library(networkD3) | |
# Two dataframes are needed: one with nodes, one with links | |
nodes <- data.frame( | |
"name" = c( | |
# Nodes at time = 1 | |
"Node A t1", # Node 0 |
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
# Packages | |
library(brickr) | |
library(rayshader) | |
library(tibble) | |
# Function that takes colours for different parts of the player model. | |
# Colour codes as per brickr::lego_colors | |
# Output is a bricks_from_table() list object | |
# Output should be fed to display_bricks() |
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
# Create a soccer player using {brickr} | |
# This file specifies some colour combinations for certain teams | |
# Blog post: https://www.rostrum.blog/2019/05/31/brickr-soccer/ | |
# You need to load some packages | |
# library(brickr) | |
# library(dray) # from remotes::install_github("matt-dray/dray") | |
# After creating a colour specification, pass it to | |
# bricks_from_table() %>% display_bricks() to render it |
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
# Demo URLs | |
urls = ['https://www.google.com', 'https://en.wikipedia.org', 'https://www.asadfxzcvgjkerty.com', 'https://www.rostrum.blog'] | |
# Set up empty list to fill with content from the for loop | |
output = [] | |
# Begin for loop | |
for url in urls: | |
try: |
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
# This isn't optimal and there's probably | |
# a function that does all this already | |
# Packages | |
library(dplyr) | |
library(purrr) | |
library(tibble) | |
# Write function | |
get_expansion <- function(x, y) { |
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
--- | |
<details><summary>Session info</summary> | |
```{r sessioninfo, echo=FALSE} | |
paste("Last updated", Sys.Date()) | |
xfun::session_info() | |
``` | |
</details> |