# Filtering cases

**Learning R**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Let’s look at some data on the U.S. Congress. Keith Poole has developed a two-dimensional procedure that places members of Congress at specific points based on roll call votes. What we’ll do now is compare Democrats and Republicans in the 110th Congress.

First, we load the data into R.

voteview <- read.csv ("C:/Data/HouseSmall.csv", header = TRUE) attach (voteview)

dems110 <- subset(voteview, party == 100 & cong == 110)

reps110 <- subset(voteview, party == 200 & cong == 110)

Now let’s create a graph to compare them.

plot (c (-1.5, 1.5), c(-1.5, 1.5), type = ‘n’,

xlab = “1st dimension”,

ylab = “2nd dimension”,

col.axis = “#777777”,

col.lab = “#777777”,

cex.axis = 0.75,

cex.lab = 1.25,

main = “DW-nominate scores, 110th Congress”,

col.main = “#444444”)

abline (v = 0, col = “#cccccc”)

points (dwnom2 ~ dwnom1, data = dems110, pch = “D”, col = “blue”, cex = 0.75)

points (dwnom2 ~ dwnom1, data = reps110, pch = “R”, col = “red”, cex = 0.75)

**leave a comment**for the author, please follow the link and comment on their blog:

**Learning R**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.