Skip to content

Instantly share code, notes, and snippets.

@dsparks
Created December 3, 2012 13:36
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsparks/4195084 to your computer and use it in GitHub Desktop.
Save dsparks/4195084 to your computer and use it in GitHub Desktop.
Running NOMINATE
doInstall <- TRUE
toInstall <- c("wnominate", "ggplot2")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
# Load most recent senate roll call data:
rollCall <- readKH("http://amypond.sscnet.ucla.edu/rollcall/static/S112.ord")
# Run wnominate on the roll call object
nDims <- 3
NOM <- wnominate(rcObject = rollCall, # The roll call object
dims = nDims, # Number of reduced dimensions
polarity = rep("PAUL (R KY)", nDims)) # A conservative
plot(NOM) # wnominate's own diagnostic plots
zp1 <- ggplot(NOM$legislators)
zp1 <- zp1 + geom_text(aes(x = coord1D, y = coord2D,
label = state, col = party))
zp1 <- zp1 + coord_equal()
zp1 <- zp1 + scale_colour_manual(values = c("BLUE", "GREEN", "RED"))
print(zp1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment