Skip to content

Instantly share code, notes, and snippets.

Emil O. W. Kirkegaard Deleetdk

View GitHub Profile
@Deleetdk
Deleetdk / scholar_bookmarklet.js
Created Nov 2, 2016
Google Scholar bookmarklet
View scholar_bookmarklet.js
/*
Function
This bookmarklet helps you quickly search Google Scholar for a given string with added keywords.
By default these keywords are words related to mortality of diseases: prognosis, life expectancy, natural history and mortality.
You can change them below.
How to use
Make a new bookmark. In the location, place the javascript code below.
*/
javascript:(function(){
View ethnocentric_dating.R
### REPLICATION OF DUNKEL AND DUTTON 2016
# Religiosity as a predictor of in-group favoritism within and between religious groups
# This assumes you have the OKCupid data loaded as d_main with various variables already created.
# recode ------------------------------------------------------------------
#own race preference
d_main$prefer_own_race = (d_main$q123 == "Yes") %>% as.factor()
table(d_main$prefer_own_race)
#religious
View ICAR_abbreviations_reliability.R
### ESTIMATE TEST-RETEST RELIABILITY OF ICAR5
library(pacman)
p_load(kirkegaard, weights, psych, magrittr, ggplot2)
#install kirkegaard from https://github.com/Deleetdk/kirkegaard if necessary
# data --------------------------------------------------------------------
#SAPA data
load("data/sapa/sapaICARData18aug2010thru20may2013.rdata")
View replication_noah_carl_submission_2016.R
### ANALYTIC REPLICATIONS OF NOAH CARL'S Explaining Terrorism Threat Level Across Western Countries
# libs --------------------------------------------------------------------
library(pacman)
p_load(XLConnect, kirkegaard, psych, weights, magrittr, effsize, lsr, compute.es, MASS)
# data --------------------------------------------------------------------
@Deleetdk
Deleetdk / egyptian_skull_size_change.R
Created Apr 26, 2016
An analysis of change in Egyptian skull sizes from -4000 to 150. Post: http://emilkirkegaard.dk/en/?p=5933
View egyptian_skull_size_change.R
### EGYPTIAN SKULLS ANALYSIS
# libs --------------------------------------------------------------------
library(pacman)
p_load(ggplot2, ade4, magrittr, reshape2, kirkegaard, plyr, psych)
# data --------------------------------------------------------------------
#load
data(skulls)
View Rape_victims_Denmark.R
library(pacman)
p_load(ggplot2, dkstat, stringr, plyr, kirkegaard)
#install kirkegaard and dkstat from github if needed
#library("devtools")
#install_github("deleetdk/kirkegaard")
#install_github("rOpenGov/dkstat")
# load data ---------------------------------------------------------------
#get meta-data
View Meng Hu's WJ analysis
library(pacman)
p_load(haven, dplyr, kirkegaard)
# load data ---------------------------------------------------------------
entiredata = read.csv("Woodcock-Johnson Murray_2007.csv")
# subset ------------------------------------------------------------------
#only first two races, and two other conditions
d = subset(entiredata, racesample < 3 & wj == 1 & sample == 1)
View Missing data example R code
library(pacman)
p_load(kirkegaard, magrittr, ggplot2)
# example dataset ---------------------------------------------------------
set.seed(1)
iris_miss = df_addNA(iris)
# amount ------------------------------------------------------------------
View Brexit prediction model
### THIS IS NOW MOSTLY REDUNDANT
### SHINY VERSION HERE: https://github.com/Deleetdk/brexit_model
# libs --------------------------------------------------------------------
library(pacman)
p_load(lubridate, rvest, stringr, kirkegaard, ggplot2, scales, boot)
# scrape data -------------------------------------------------------------
#get newest data on website
View Re-analyze Beaver and Wright's correlation matrix
### re-analyze Beaver and Wright's correlation matrix
library(magrittr)
# load data ---------------------------------------------------------------
#load matrix
d_bw = structure(list(IQ = c(1, -0.4, -0.44, -0.29, -0.51, -0.58, -0.54, -0.52, -0.53, -0.49, -0.43, -0.56, -0.27, -0.46, -0.38), Property.crime = c(-0.4, 1, 0.95, 0.97, 0.76, 0.77, 0.69, 0.72, 0.93, 0.32, 0.44, 0.56, 0.12, 0.13, 0.16), Burglary = c(-0.44, 0.95, 1, 0.88, 0.7, 0.79, 0.68, 0.75, 0.92, 0.46, 0.56, 0.64, 0.25, 0.27, 0.27), Larceny = c(-0.29, 0.97, 0.88, 1, 0.59, 0.64, 0.53, 0.62, 0.83, 0.27, 0.42, 0.5, 0.13, 0.05, 0.09), Motor.vehicle.theft = c(-0.51, 0.76, 0.7, 0.59, 1, 0.84, 0.88, 0.69, 0.89, 0.19, 0.18, 0.44, -0.09, 0.13, 0.14), Violent.crime = c(-0.58, 0.77, 0.79, 0.64, 0.84, 1, 0.91, 0.93, 0.94, 0.57, 0.6, 0.76, 0.23, 0.46, 0.39), Robbery = c(-0.54, 0.69, 0.68, 0.53, 0.88, 0.91, 1, 0.7, 0.87, 0.36, 0.38, 0.62, 0.03, 0.28, 0.23), Aggravated.assault = c(-0.52, 0.72, 0.75, 0.62, 0.69, 0.93, 0.7, 1, 0.86, 0.66, 0.69, 0.76, 0.36, 0.55, 0
You can’t perform that action at this time.