Skip to content

Instantly share code, notes, and snippets.

@vanatteveldt
Last active August 29, 2015 13:56
Show Gist options
  • Save vanatteveldt/8821524 to your computer and use it in GitHub Desktop.
Save vanatteveldt/8821524 to your computer and use it in GitHub Desktop.
library(reshape)
library(foreign)
library(irr)
# prepare data as 'molten' article - coder - issue - variable - value rows
b = read.spss("betrouwbaarheid.sav", to.data.frame=T)
d = b[, c("Coder","ArticleId", "Sourcepartytype", "Subjectpartytype", "Objectpartytype","Sourcedim", "Subjectdim", "Objectdim" )]
d = melt(d, id.vars=c("Coder","ArticleId"))
d$party = grepl("partytype", d$variable)
d = d[!is.na(d$value), ]
# noemen partijen, 4 cat (coa, opp, new, strucopp) in 'Xpartytype' variables -> $party = T
e = cast(d[d$party,], ArticleId + value ~ Coder , fun.aggregate=length)
all = merge(data.frame(ArticleId=unique(b$ArticleId)), data.frame(value=unique(e$value)), by=NULL)
all = merge(all, e, all.x=T)
all[is.na(all)] = 0
m = all[, -1:-2]
kripp.alpha(t(m), method="interval")
mkjb = all[,match(c("kim", "Jessica", "brechje", "Sjoerd"), colnames(all))]
kripp.alpha(t(mkjb), method="interval")
# noemen issues, polen van dimensies in 'Xdim' variables -> $party = F
e = cast(d[!d$party,], ArticleId + value ~ Coder , fun.aggregate=length)
all = merge(data.frame(ArticleId=unique(b$ArticleId)), data.frame(value=unique(e$value)), by=NULL)
all = merge(all, e, all.x=T)
all[is.na(all)] = 0
m = all[, -1:-2]
kripp.alpha(t(m), method="interval")
mkjb = all[,match(c("kim", "Jessica", "brechje", "Sjoerd"), colnames(all))]
kripp.alpha(t(mkjb), method="interval")
# noemen issues, alleen 5 dimensies
d$dim = NA
d$dim[d$value %in% c("left", "right")] = "econom"
d$dim[d$value %in% c("green", "grey")] = "envir"
d$dim[d$value %in% c("cosmopolitic", "nationalistic")] = "open"
d$dim[d$value %in% c("consensus", "Negative Valence")] = "valence"
d$dim[d$value %in% c("libertarian", "conservative")] = "progres"
e = cast(d[!is.na(d$dim),], ArticleId + dim ~ Coder , fun.aggregate=length)
all = merge(data.frame(ArticleId=unique(b$ArticleId)), data.frame(dim=unique(e$dim)), by=NULL)
all = merge(all, e, all.x=T)
all[is.na(all)] = 0
m = all[, -1:-2]
kripp.alpha(t(m), method="interval")
mkjb = all[,match(c("kim", "Jessica", "brechje", "Sjoerd"), colnames(all))]
kripp.alpha(t(mkjb), method="interval")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment