library(RCPA3)POL 300: Lab 4
This page contains R code for Lab 4.
Instructions
To complete this lab:
- create a new R script on your computer
- save it under the name
POL 300 Lab 4.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
setwd(dirname(rstudioapi::getSourceEditorContext()$path))
getwd()states$prcapinc.thou <- states$prcapinc / 1000
head(data.frame(states$state, states$prcapinc, states$prcapinc.thou))world$conflict.index2 <- 5 - world$peace.indexlevels(states$judge.selection)
states$judges.partisan.elect <- transformC(type="dummy", x=judge.selection, data=states, response="Partisan election")
freqC(states$judges.partisan.elect)
these.values <- c("Partisan election", "Non-partisan election")
states$judges.elected2 <- transformC(type="dummy", x=judge.selection, data=states, response=these.values)
freqC(states$judge.selection, plot=F)
freqC(states$judges.elected2, plot=F)describeC(states$unionized)
states$unionized.4cat <- transformC("cut", x=states$unionized, cutpoints=c(5, 10, 15))
freqC(states$unionized.4cat)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)