Skip to content

Instantly share code, notes, and snippets.

@RCura
Last active August 29, 2015 14:18
Show Gist options
  • Save RCura/12ccc4b2c81dd00410d0 to your computer and use it in GitHub Desktop.
Save RCura/12ccc4b2c81dd00410d0 to your computer and use it in GitHub Desktop.
OC bug
rank correctYea wrongYea wrongNay correctNay volume coord1D coord2D
Legis1 9.5 1 0 0 3 0.154 0.1393427 2.439471e-04
Legis2 9.5 1 0 0 3 0.213 0.1393427 2.439471e-04
Legis3 7.0 2 0 0 2 0.131 0.1392035 -9.211715e-25
Legis4 7.0 2 0 0 2 0.029 0.1392035 -9.211715e-25
Legis5 7.0 2 0 0 2 0.070 0.1392035 -9.211715e-25
Legis6 3.0 0 0 0 0 0.000 0.0000000 0.000000e+00
Legis7 3.0 0 0 0 0 0.000 0.0000000 0.000000e+00
Legis8 3.0 0 0 0 0 0.000 0.0000000 0.000000e+00
Legis9 3.0 0 0 0 0 0.000 0.0000000 0.000000e+00
Legis10 NA NA NA NA NA NA NA NA
Legis11 3.0 0 0 0 0 0.000 0.0000000 0.000000e+00
baseDF <- structure(list(V1 = c(1, 1, 1, 1, 1, 1, 6, 1, 6, 0, 1), V2 = c(1, 6, 6, 6, 6, 6, 1, 6, 8, 0, 6), V3 = c(9, 6, 6, 6, 8, 6, 9, 6, 1, 0, 6), V4 = c(1, 9, 6, 6, 1, 1, 1, 1, 1, 0, 1)), .Names = c("V1", "V2", "V3", "V4"), row.names = c("Legis1", "Legis2", "Legis3", "Legis4", "Legis5", "Legis6", "Legis7", "Legis8", "Legis9", "Legis10", "Legis11"), class = "data.frame")
legisNames <- row.names(baseDF)
voteNames <- c("Vote1", "Vote2", "Vote3", "Vote4")
library(pscl)
outputHRR <- rollcall(data = baseDF,
yea = 1, nay = 6, missing = c(8,9), notInLegis = 0,
legis.names = legisNames, vote.names = voteNames)
library(oc)
outputOC <- oc(rcObject = outputHRR,
dims = 2, minvotes = 1,
polarity = c(1,9))
outputResults <- outputOC$legislators
outputResults
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment