Skip to content

Instantly share code, notes, and snippets.

View Deleetdk's full-sized avatar

Emil O. W. Kirkegaard Deleetdk

View GitHub Profile
"LD_* scout runtime" information:
{
"can-write-uinput" : true,
"steam-installation" : {
"path" : "/home/emil/.steam",
"data_path" : "/home/emil/.steam",
"bin32_path" : "/home/emil/.steam/ubuntu12_32",
"steamscript_path" : "/usr/bin/steam",
"steamscript_version" : "1.0.0.78",
"issues" : [
System:
Host: computer Kernel: 5.15.0-89-generic x86_64 bits: 64
Desktop: Cinnamon 5.6.8 Distro: Linux Mint 21.1 Vera
Machine:
Type: Desktop System: ASUS product: N/A v: N/A serial: <superuser required>
Mobo: ASUSTeK model: Pro WS WRX80E-SAGE SE WIFI II v: Rev 1.xx
serial: <superuser required> UEFI: American Megatrends v: 0204
date: 11/10/2022
CPU:
Info: 16-core model: AMD Ryzen Threadripper PRO 5955WX s bits: 64
@Deleetdk
Deleetdk / interracial rapes.R
Created February 15, 2023 05:38
interracial rape stats
library(googlesheets4)
library(kirkegaard)
theme_set(theme_bw())
#read data
d = read_sheet("https://docs.google.com/spreadsheets/d/1cPApEVEPNj4DXTB7LN7hd7B6WxYQiottbfHFt72tCzE/edit#gid=0")
#transform to long form for plotting
d_long = d %>%
@Deleetdk
Deleetdk / sibling SD.R
Created January 9, 2023 20:40
sibling SD
library(tidyverse)
#simulate datasets
sibs = 20
x = map_df(seq(0, 1, .01), function(r) {
#simulate sibling scores at correlation r
matrix = matrix(r, ncol = sibs, nrow = sibs)
diag(matrix) = 1
mvrnorm(n = 1e4,
Sigma = matrix,
@Deleetdk
Deleetdk / pairwise_cors.R
Created December 12, 2022 06:56
pairwise correlation with crosses
library(kirkegaard)
#get cors with p values
cors = iris[-5] %>%
wtd.cor()
cors = mpg[map_lgl(mpg, is.numeric)] %>%
wtd.cor()
#long format
@Deleetdk
Deleetdk / clean_metadata.R
Created September 10, 2022 15:19
remove metadata linux with R
#!/usr/bin/env Rscript
library(stringr)
#scape spaces
escape_spaces = function(x) {
str_replace_all(x, fixed(" "), "\\ ")
}
#get args
args = commandArgs(trailingOnly=TRUE)
#CRAN versions dont work
#devtools::install_github("lmullen/gender")
#devtools::install_github("lmullen/genderdata")
library(rvest)
library(kirkegaard)
library(gender)
library(patchwork)
theme_set(theme_classic())
@Deleetdk
Deleetdk / scholar_bookmarklet.js
Created November 2, 2016 23:18
Google Scholar bookmarklet
/*
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(){
### 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
### 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