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
Run R Demo
i
Online demo using xtabC function from poliscidata package..
 Controlled Cross Tabulation of Marijuana Opinions Demo.
thumbnail preview
â–º
i
Quick and easy way to generate histograms for interval-level variables, from Barry Edwards (10:50).
 How to Use RCPA3's histC Function to Generate Histograms
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