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)  # run every time

# Creating a numeric indicator variable
gss$veteran = gss$vetyears != "NONE"    # Any years of service yields TRUE
gss$veteran = as.numeric(gss$veteran)   # TRUE and FALSE values now 1s and 0s

# the freq dist tables not strictly necessary but you should check your work
cat("Frequency Distribution Table (Original Variable):\n")
freq(gss$vetyears, plot=F)             # Make sure indicator variable correct

cat("\nFrequency Distribution Table (New Variable):\n")
freq(gss$veteran, plot=F)              # by comparing frequencies
Watch & Learn
thumbnail preview
â–º
i
Video tutorial & demo by Barry Edwards for R Companion to Political Analysis, 3rd Ed. (13:30).
 Create Cross-Tabulations to Make Comparisons With RCPA3's CrosstabC Function
Run R Demo
i
Box plots of interval variable by factor, weighted observations..
 Box Plot of Hillary Clinton Rating by Party ID 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