POL 300: Lab 6

Author

Dr. Annie Karreth

This page contains R code for Lab 6.

Instructions

To complete this lab:

  • create a new R script on your computer
  • save it under the name POL 300 Lab 6.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()
regC(formula = trump2020 ~ foreign.born, data=states)

plot(x=states$foreign.born, y=states$trump2020)

abline (a=0.62, b=-0.011)
regC(formula = vep20.turnout ~ battleground2020, 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")