This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ################################# | |
# WORDSCORES AND WORDFISH ANALYSIS | |
# ################################# | |
# setup | |
library(austin) | |
############################ | |
# GETTING DOCUMENTS IN | |
############################ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
die | |
und | |
der | |
in | |
zu | |
für | |
mit | |
ist | |
sich | |
den |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Code by Matt Asher for statisticsblog.com | |
# Feel free to modify and redistribute | |
# How many flakes do you want to fall? | |
flakes = 100 | |
# Width and height of your space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(agrmt) # install from R-Forge | |
# Data: | |
V <- c(0,0,1,2,1.5,1.6) | |
# AJUS | |
ajus(V) # using default tolerance = 0.1 | |
ajusPlot(V) # visual inspection | |
ajus(V, tolerance=0.2) # exploring | |
ajusCheck(V, t=seq(0.1,2,0.1)) # let's try them all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
miss <- !is.na(variable.name[country=="UK") | |
plot(which(miss), variable.name[country=="UK" & miss], col="red", type="b", lwd=2, axes=FALSE, xlim=c(1,16)) | |
axis(2) | |
axis(1,at=c(1,6,11,16), labels=c("1995","2000","2005","2010")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
as_pdf <- function(x){ | |
require(tools) | |
fname <- tempfile(pattern = "texview-", tmpdir = tempdir(), | |
fileext = ".tex") | |
header <- "\\documentclass{article} | |
\\usepackage[margin=10pt,font=small,labelformat=empty, | |
labelsep=none]{caption} | |
\\usepackage{dcolumn} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" page-range-format="chicago" demote-non-dropping-particle="sort-only"> | |
<info> | |
<title>Ethnic and Racial Studies</title> | |
<id>http://www.zotero.org/styles/ethnic-and-racial-studies</id> | |
<link href="http://www.zotero.org/styles/ethnic-and-racial-studies" rel="self"/> | |
<link href="www.tandfonline.com/action/authorSubmission?journalCode=rers20&page=instructions" rel="documentation"/> | |
<author> | |
<name>Didier Ruedin</name> | |
<email>didier.ruedin@wolfson.oxon.org</email> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namav <- function(x,k=3){ | |
x <- c(rep(NA, k),x,rep(NA,k)) # add NA on both sides | |
n <- length(x) | |
return(sapply((k+1):(n-k), function(i) sum(x[(i-k):(i+k)],na.rm=TRUE)/(2*k+1-sum(is.na(x[(i-k):(i+k)]))))) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(psych) | |
n <- 5000 | |
x <- rnorm(n) # random values | |
r <- sapply(1:n, function(i) alpha(data.frame(x, c(x[1:i],rep.int(0,n-i))))$total$std.alpha) | |
plot(r, type="l", ylim=c(0,1), xlim=c(0,n), axes=FALSE, ylab="Alpha", xlab="Zero-Inflation (%)") | |
axis(2) | |
axis(1, at=seq(from=0,to=n,by=n/5), labels=seq(from=0,to=100,by=20)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plzcanton <- function(PLZ, format=1) { | |
# convert Swiss postcode to canton; v.0.4 (20 Nov 2020) didier.ruedin@unine.ch | |
# format 1 = numeric | |
# format 2 = string | |
# DATA: BFS canton numbers: | |
clabels <- c("ZH", "BE", "LU", "UR", "SZ", "OW", "NW", "GL", "ZG", "FR", "SO", "BS","BL", "SH", "AR", "AI", "SG", "GR", "AG", "TG", "TI", "VD", "VS", "NE", "GE", "JU") | |
# DATA: postcodes: | |
ZH <- c(8970, 8955, 8954, 8953, 8952, 8951, 8942, 8934, 8933, 8932, 8926, 8925, 8915, 8914, 8913, 8912, 8911, 8910, 8909, 8908, 8907, 8906, 8904, 8903, 8902, 8901, 8833, 8825, 8824, 8820, 8816, 8815, 8813, 8812, 8810, 8805, 8804, 8803, 8802, 8801, 8800, 8714, 8713, 8712, 8708, 8707, 8706, 8704, 8703, 8702, 8700, 8639, 8637, 8636, 8635, 8634, 8633, 8632, 8630, 8627, 8626, 8625, 8624, 8623, 8622, 8621, 8620, 8618, 8617, 8616, 8615, 8614, 8613, 8612, 8610, 8608, 8607, 8606, 8605, 8604, 8603, 8602, 8600, 8548, 8545, 8544, 8543, 8542, 8523, 8499, 8498, 8497, 8496, 8495, 8494, 8493, 8492, 8489, 8488, 8487, 8486, 8484, 8483, 8482, 8479 |
OlderNewer