Created
December 3, 2012 13:36
-
-
Save dsparks/4195084 to your computer and use it in GitHub Desktop.
Running NOMINATE
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
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