POL 300: Lab 5

Author

Dr. Annie Karreth

This page contains R code for Lab 5.

Instructions

To complete this lab:

  • create a new R script on your computer
  • save it under the name POL 300 Lab 5.R
  • copy and paste the code from this page (in the gray boxes) into the script
  • comment the code as instructed during the lab

Code

library(RCPA3)
setwd(dirname(rstudioapi::getSourceEditorContext()$path))
getwd()
freqC(x=lifex.sharkbite, data=nes)
freqC(x=russia.int.election, data=nes)
histC(x=corrections.incarc.rate, data=states)
crosstabC(dv=icc.treaty.ratified, 
          iv=region, 
          data=world, 
          plot="bar", 
          plot.response="Yes", 
          main="ICC Treaty Ratification by Region")
crosstabC(dv=states$tax.source, 
          iv=states$region, 
          plot="bar", 
          plot.response="all", 
          compact=T)
crosstabC(dv=rights.injud, 
          iv=region, 
          data=world, 
          plot="bar", 
          compact=T, 
          digits=1, 
          plot.response="Generally independent")
crosstabC(dv=rights.injud, 
          iv=gdp.percap.5cat, 
          data=world, 
          plot="line", 
          digits=1, 
          compact=T, 
          plot.response="Generally independent")
crosstabC(dv=rights.injud, iv=gdp.percap.5cat, data=world,
          digits=1, compact=T, plot="mosaic",
          dvlabs=c("Not independent", "Partial", "Full"),
          ivlabs=c("<$3k", "$3-10k", "$10-25k", "$25-45k", "$45+k"),
          xlab="National Per Capita Income",
          ylab="Extent of Judicial Independence",
          main="Relationship between Nat'l Income & Judicial Indep.")
boxplotC(dv = infant.mortality, 
         iv = region, 
         data = world,
         main = "Infant mortality by region",
         xlab = "",
         ylab = "Infant mortality")
plot(x = world$gdp.percap, 
     y = world$infant.mortality,
     xlab = "Per Capita Gross Domestic Product",
     ylab = "Infant Mortality Rate",
     main = "Relationship between Per Capita GDP & Infant Mortality")