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

# indicator variable created for each abortion variable
# this is going to run without console output
gss$abdefect.n    = as.numeric(gss$abdefect=="YES")
gss$abhlth.n 	= as.numeric(gss$abhlth  =="YES")
gss$abnomore.n	= as.numeric(gss$abnomore=="YES")
gss$abpoor.n 	= as.numeric(gss$abpoor  =="YES")
gss$abrape.n 	= as.numeric(gss$abrape  =="YES")
gss$absingle.n	= as.numeric(gss$absingle=="YES")
gss$abany.n 	= as.numeric(gss$abany   =="YES")

# individual indicators added together to create 0-7 scale
# this does not create console output
gss$abortion.scale = gss$abdefect.n + gss$abhlth.n + gss$abnomore.n +  
  gss$abpoor.n   + gss$abrape.n + gss$absingle.n + 
  gss$abany.n

# describe the additive index to see results
cat("Frequency Distribution Table:")
freqC(gss$abortion.scale, gss$wtss)
Watch & Learn
Run R Demo
i
Online demo using imeansC and iplotC functions from poliscidata package..
 Controlled Mean Comparison of Democratic Party Ratings Demo.
thumbnail preview
â–º
i
By Roger Peng (16:08).
 Overview and History of R
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