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)

::: {.cell}

```{.r .cell-code}
levels(nes$immig.levels)

nes$immig.levels.3cat <- ordered(nes$immig.levels,
labels=c("1. Increased", "1. Increased", "2. Left the same", "3. Decreased", "3. Decreased"))

freqC(nes$immig.levels)
freqC(nes$immig.levels.3cat)

:::

crosstabC(dv=abortlaws.3cat, iv=religiosity3, data=states)

crosstabC(dv=abortlaws.3cat, iv=religiosity3, data=states, chisq=T)

crosstabC(dv=frac.eth2, iv=election.violence.post, data=world, chisq=T)
compmeansC(dv=coup.attempts, iv=dpi.system, data=world)
world$infant.mortality.3cat <- transformC("cut",x=world$infant.mortality,
                                          groups=3)

freqC(x=infant.mortality.3cat, data=world)

compmeansC(dv=fertility, iv=infant.mortality.3cat, data=world,
           plot="line", ivlabs=c("Low", "Moderate", "High"))