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
# Simplify image colours to prespecified simple colour set | |
# Following Jeroen Ooms (https://jeroen.github.io/munster2018/) | |
library(magick) | |
library(dplyr) | |
library(tibble) | |
# read test image | |
# img_path <- "https://upload.wikimedia.org/wikipedia/commons/1/13/Suprematist_Composition_-_Kazimir_Malevich.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
# Shiny app with checkboxes | |
# If unchecked, no error | |
# https://stackoverflow.com/a/38686474 | |
# https://stackoverflow.com/a/37737182 | |
library(shiny) | |
library(ggplot2) | |
library(dplyr) | |
ui <- shinyUI(fluidPage( |
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 virtual environment at current pwd | |
virtualenv venv | |
# Activate the virtual environment | |
source venv/bin/activate | |
# Load in module/version requirements | |
pip install -r requirements.txt | |
# Deactivate the running virtual environment |
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
# Branch activities | |
git branch # current branch | |
git branch -a # list all branches | |
git branch -av # list branches with last commit | |
git checkout branch-name # switch to branch | |
# Git stashing | |
# For storing changes when you switch branch and come back later | |
# https://git-scm.com/book/en/v1/Git-Tools-Stashing | |
git stash push |
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(rvest) | |
library(tibble) | |
nba_wikipedia <- read_html("https://en.wikipedia.org/wiki/National_Basketball_Association") | |
nba_table <- html_nodes( | |
x = nba_wikipedia, | |
xpath = '//*[@id="mw-content-text"]/div/table[4]' | |
) %>% | |
html_table(fill = TRUE, header = NA) |
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 2.
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
"tID","bpID","priority","certainty","errorTitle","standards","resultTitle","errorDescription","viewPortLocation","position","errorSnippet","xpath","issueID","signature","ref","url" | |
3,118,100,100,"The language of this page is not set.","Web Content Accessibility Guidelines (WCAG) 2.0, Level A: 3.1.1 Language of Page","Identify the natural language for the page","The language of the document has not been set. When the language is not set, screen readers and other assistive technologies have no way of being sure of the correct way to accessibily present the contents.","{""top-left"":{""x"":0,""y"":0},""bottom-right"":{""x"":1024,""y"":768},""height"":768,""width"":1024}","column: 1 , line: 1","<html><head style="""">\n\n <meta charset=""UTF-8"" style="""">\n <meta http-equiv=""X-UA-Compatible"" content=""IE=edge"" style="""">\n <title style="""">RAP Companion</title>\n <meta name=""description"" content=""A technical commu","/html","e14ae3f19fc00ece6488db9c9b459586","3cc1161591cd0a1f606898e98ddeb0d6","https: |
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 of alluvial::alluvial() | |
# see the vignette: https://cran.r-project.org/web/packages/alluvial/vignettes/alluvial.html | |
# matt dray | |
# july 2018 | |
# packages | |
library(dplyr) | |
library(readr) | |
library(alluvial) |
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") | |
) %>% |