NOW AVAILABLE: Essentials of Poltical Analysis 7e | R Companion 4e | SPSS 7e | Stata 5e | Excel 1e 🎵
NOW AVAILABLE: Essentials 7e | R Companion 4e | SPSS 7e | Stata 5e | Excel 1e 🎵
NOW AVAILABLE: Essentials 7e | More Textbooks 🎵

Run R Code Example Online

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)