Skip to content

Instantly share code, notes, and snippets.

View matt-dray's full-sized avatar
®️

Matt Dray matt-dray

®️
View GitHub Profile
@matt-dray
matt-dray / swfc_2016_headcount.csv
Last active June 18, 2018 08:48
School Workforce Census 2016: processed version of original CSV containing columns for school details and headcount data.
We can't make this file beautiful and searchable because it's too large.
la_number,establishment_number,la_name,urn,school_name,school_type,school_phase,region,workforce_count,class_teacher_count,teacher_count,ta_count,aux_staff_count
201,3614,City of London,100000,Sir John Cass's Foundation Primary School,LA maintained schools,Primary,Inner London,46,15,20,16,1
202,1048,Camden,100005,Thomas Coram Centre,LA maintained schools,Nursery,Inner London,36,3,6,13,8
202,1100,Camden,100006,CCfL Key Stage 4 PRU,LA maintained schools,Not applicable,Inner London,22,7,10,9,2
202,1101,Camden,100007,Camden Primary Pupil Referral Unit,LA maintained schools,Not applicable,Inner London,28,13,15,11,0
202,1103,Camden,134643,CCfL Key Stage 3 PRU,LA maintained schools,Not applicable,Inner London,14,3,5,6,0
202,2000,Camden,136807,St Luke's Church of England Primary,Free Schools,Primary,Inner London,16,4,6,7,1
202,2001,Camden,139837,Abacus Belsize Primary School,Free Schools,Primary,Inner London,12,4,6,5,0
202,2002,Camden,140686,Kings Cross Academy,Academies,Primary,Inner London,2,0,0,1,1
202,2019,Camden
@matt-dray
matt-dray / swfc_2016_fte.csv
Last active June 17, 2018 19:35
School Workforce Census 2016: processed version of original CSV containing columns full-time equivalent data and the joining key of URN (establishment Unique Reference Number).
We can't make this file beautiful and searchable because it's too large.
urn,workforce_fte,class_teacher_fte,teacher_fte,ta_fte,aux_fte
100000,32.4,10.3,14.3,11.3,1
100005,29.9,2,4.3,13,4.8
100006,22,7,10,9,2
100007,26.6,11.8,13.8,10.8,0
134643,14,3,5,6,0
136807,11.7,2.8,4.8,4.3,1
139837,10.6,3.7,5.7,4.2,0
140686,1,0,0,0.6,0.4
100008,53.2,16.8,20.4,17.1,9.7
@matt-dray
matt-dray / alluvial_demo.R
Last active January 4, 2019 17:06
Testing the alluvial function for creating Sankey-like static plots
# 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)
@matt-dray
matt-dray / get_gias.R
Last active September 19, 2018 13:16
Download today's latest Get Information About Schools data
# This code sources the CSV for GIAS from online
# The URL is in the form [standard path][creation date][.csv], so we can just
# change the creation date to today's date using Sys.Date()
gias <- data.table::fread(
paste0(
"http://ea-edubase-api-prod.azurewebsites.net/edubase/edubasealldata",
stringr::str_replace_all(Sys.Date(), "-", ""),
".csv"
)
bpID certainty errorDescription errorSnippet errorTitle issueID position priority ref resultTitle signature standards tID viewPortLocation xpath url
1 100 All images need an `alt` attribute. If you do not supply an `alt` attribute, that'll mean that users who ca not see the image will not understand what the image conveys. Make sure that the `alt` attribute value is a useful, concise, and clear description of the image. <img src="/images/hugo-logo.png" width="22" height="22"> This image is missing an `alt` attribute. 9b8bacf51f4a8ca12088ea7f9127f620 column: 77 , line: 197 97 https://tenon.io/bestpractice.php?bpID=1&tID=9 Provide an alt attribute for each `&lt;img&gt;` element. 0b423978ffbad8c6f96648e1938f17eb Web Content Accessibility Guidelines (WCAG) 2.0, Level A: 1.1.1 Non-text Content 9 {"bottom-right":{"x":612.484375,"y":9819.96875},"height":22,"top-left":{"x":590.484375,"y":9797.96875},"width":22} /html/body/div[1]/footer[1]/ul[1]/li[2]/a[1]/img[1] https://www.rostrum.blo
@matt-dray
matt-dray / join-data-two-databases.R
Last active September 19, 2018 13:09
Use odbc and DBI to connect to two SQL databases, query them and join the outputs
# Connecting R to SQL (with DBI and odbc)
# Original: 18 July 2018
# Matt Dray
# Goal: join two datasets from different databases
# Basic approach:
# 1. Connect to database A, perform query, disconnect
# 2. As above for database B
# 3. Join the two dataframes returned from steps 1 and 2
library(dplyr)
library(Rcrawler)
library(purrr)
library(httr)
x <- c(
"https://rostrum.blog",
"https://therostrumblog.wordpress.com/"
)
@matt-dray
matt-dray / embed_iframe.R
Created September 17, 2018 13:50
Embed slides into blogdown
knitr::include_url("https://matt-dray.github.io/earl18-presentation/")
@matt-dray
matt-dray / sparklyr-test.R
Created September 21, 2018 13:56
Testing the sparklyr package for Coffee & Coding
# Testing sparklyr for Coffee & Coding
# Matt Dray
# 29 Nov 2017
# Following https://spark.rstudio.com/
# R 3.4.2 & RStudio 1.1.383
# What? -------------------------------------------------------------------
@matt-dray
matt-dray / dbi-odbc-join.R
Created September 21, 2018 14:00
Example of getting data from two different SQL databases and joining them in R
# Coffee & Coding: connecting R to SQL (with DBI and odbc)
# DfE-scpecific example
# 18 July 2018
# Session: Cathy
# This script: Matt
# Basic approach:
# 1. Connect to database A, perform query, disconnect
# 2. As above for database B
# 3. Join the two dataframes returned from steps 1 and 2