Skip to content

Instantly share code, notes, and snippets.

View kjhealy's full-sized avatar

Kieran Healy kjhealy

View GitHub Profile
@kjhealy
kjhealy / epl_goal_contribution_matrix_18-19.r
Created May 19, 2019 19:43 — forked from Ryo-N7/epl_goal_contribution_matrix_18-19.r
Goal contribution matrix for Premier League 2018-2019
# pkgs
pacman::p_load(tidyverse, polite, scales, ggimage, ggforce,
rvest, glue, extrafont, ggrepel, magick)
loadfonts()
## add_logo function from Thomas Mock
add_logo <- function(plot_path, logo_path, logo_position, logo_scale = 10){
# Requires magick R Package https://github.com/ropensci/magick
## Start with the code in https://github.com/kjhealy/lexis_surface/blob/master/lexis.r
## At the bottom, the `fra_surface` object is done in 3D with the `plotly` library. We can
## also do it with `rayshade`:
library(rayshader)
## rayshade wants the axes a little differently from plotly
## but like plotly it wants a matrix.
fra_surf <- fra_surf[c(1:201),c(100:1)]
@kjhealy
kjhealy / join-animations-with-gganimate.R
Created August 15, 2018 12:18 — forked from gadenbuie/join-animations-with-gganimate.R
Animated dplyr joins with gganimate
# Animated dplyr joins with gganimate
# * Garrick Aden-Buie
# * garrickadenbuie.com
# * MIT License: https://opensource.org/licenses/MIT
# Note: I used Fira Sans and Fira Mono fonts.
# Use search and replace to use a different font if Fira is not available.
library(tidyverse)
library(gganimate)
library(XML)
library(ggplot2)
df <- readHTMLTable("http://projects.dailycal.org/paychecker")[[1]]
colnames(df)[4] <- "Salary"
df$Salary <- as.numeric(gsub('[$,]', '', df$Salary))
p <- ggplot(df, aes(x=Department, y=Salary)) + coord_flip()
p + geom_boxplot(aes(color=Rank,
x=reorder(Department, Salary, FUN=max))) +
library(XML)
library(ggplot2)
df <- readHTMLTable("http://projects.dailycal.org/paychecker/departments/")[[1]]
DeMoney <- function(x) as.numeric(gsub(",", "", gsub("\\$", "", as.character(x))))
money.columns <- c("All", "Professor", "Associate professor", "Assistant professor",
"Lecturer")
@kjhealy
kjhealy / biclique.r
Created March 13, 2017 20:41
Biclique function
## Lehmann, Schwartz, and Hansen (2008)
## For use with igraph objects
## via http://stackoverflow.com/questions/31024481/detect-bi-cliques-in-r-for-bipartite-graph
library(igraph)
computeBicliques <- function(graph, k, l) {
vMode1 <- c()
if (!is.null(V(graph)$type)) {
@kjhealy
kjhealy / z-automator.png
Created November 17, 2016 19:10 — forked from lrytz/z-automator.png
Shortcut for Syntax Highlighting in Keynote

title: Lorem Ipsum author:

  • name: Marion Fourcade affiliation: University of California, Berkeley email: [email protected]
  • name: Kieran Healy affiliation: Duke University email: [email protected] date: October 2015
@kjhealy
kjhealy / Makefile
Last active November 25, 2021 08:54
Rmd to md, html, tex, pdf
### From Rmd to PDF or html
## All Rmarkdown files in the working directory
SRC = $(wildcard *.Rmd)
## Location of Pandoc support files.
PREFIX = /Users/kjhealy/.pandoc
## Location of your working bibliography file
BIB = /Users/kjhealy/Documents/bibs/socbib-pandoc.bib

Keybase proof

I hereby claim:

  • I am kjhealy on github.
  • I am kjhealy (https://keybase.io/kjhealy) on keybase.
  • I have a public key whose fingerprint is 02A0 1BC1 9860 B68F 5170 EC1D 2FA5 B859 36DB 10A2

To claim this, I am signing this object: