FIND DATA: By Author | Journal | Sites   ANALYZE DATA: Help with R | SPSS | Stata | Excel   WHAT'S NEW? US Politics | Int'l Relations | Law & Courts
   FIND DATA: By Author | Journal | Sites   WHAT'S NEW? US Politics | IR | Law & Courts
Run R Code
About This Page
This page features live demonstrations of the R Statistics Program used for political science research.
  • To run example, click the Run button.
  • To copy example code, click the Copy button.


See More R Demos
Run R Code in Your Web Browser
library(poliscidata)

# Collapsing numeric variables into substantively useful categories
describe(gss$age, weights=gss$wtss)
gss$age7 = cut2(gss$age, c(21, 31, 41, 51, 61, 71, 89))
levels(gss$age7) = c("18-20", "21-30", "31-40", "41-50", "51-60", "61-70",  "71-")
gss$age7 = as.ordered(gss$age7)

# the next two lines not strictly necessary but should check our work
levels(gss$age7)
freq(gss$age7, gss$wtss, plot=F)
Watch & Learn
thumbnail preview
â–º
i
From David Caughlin (18:00).
 Creating Tables
Run R Demo
i
Explore contents of a dataset (the 2016 NES) and variable in dataset..
 Explore NES Dataset Demo
MORE VIDEOS: See Video Channels for more political science videos!
LEARN HOW: Watch Lecture Videos for Essentials of Political Analysis, Video Tutorials for R, Stata, SPSS, and Excel