Skip to content

Instantly share code, notes, and snippets.

View Deleetdk's full-sized avatar

Emil O. W. Kirkegaard Deleetdk

View GitHub Profile
### 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 April 26, 2016 03:11
An analysis of change in Egyptian skull sizes from -4000 to 150. Post: http://emilkirkegaard.dk/en/?p=5933
### EGYPTIAN SKULLS ANALYSIS
# libs --------------------------------------------------------------------
library(pacman)
p_load(ggplot2, ade4, magrittr, reshape2, kirkegaard, plyr, psych)
# data --------------------------------------------------------------------
#load
data(skulls)
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
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)
library(pacman)
p_load(kirkegaard, magrittr, ggplot2)
# example dataset ---------------------------------------------------------
set.seed(1)
iris_miss = df_addNA(iris)
# amount ------------------------------------------------------------------
### 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
### 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
library(pacman)
p_load(curl, kirkegaard)
# fetch lists of stations -------------------------------------------------
for (i in 1:56) {
message(i)
#if i < 10, pad 0
#!/bin/bash
for ID in {1..56}
do
#pad 0's
size = ${#ID}
if [ $size == 1 ]
then
ID = "0" + $ID
fi
@Deleetdk
Deleetdk / chorion_effects.R
Last active March 19, 2016 06:33
R analysis of chorion effects on heritability/ACE estimation
# libs --------------------------------------------------------------------
library(pacman)
p_load(stringr, psych, kirkegaard, psychometric)
# data --------------------------------------------------------------------
d_table = read.csv("chorion_data.csv", row.names = 1)
# extract data ------------------------------------------------------------
#find MC and DC rows