#Title: dwv_ps6_ms_4_base.R #Author: Jack Reilly #Purpose: Load data # requires: working directory, libraries, gss_collapse # result: fig1, 2, 5 in base R (to viewer) #Figure 1 #Let's do it properly nice, with layering in base R plot(x=0, type='n', xlim=c(1976, 2021), xaxt = "n", ylim=c(0,15), yaxt = "n", xlab="Year", ylab="Stouffer", main="Figure 1. The 0-15 GSS Modified Stouffer Tolerance Battery, 1976-2021") axis(1, at = c(1976, 2021)) #1 says "bottom axis" axis(2, at = c(0, 15)) #2 says "left axis" lines(gss_collapse$year, gss_collapse$stouffer, lwd=2) #We gotta do it the real way this time #Why? we don't know which version of the data we're getting - this will reflect whatever it is v77<-gss_collapse$stouffer[gss_collapse$year == 1977] v98<-gss_collapse$stouffer[gss_collapse$year == 1998] v21<-gss_collapse$stouffer[gss_collapse$year == 2021] #Round and paste it in text(1985, 8, paste(round(v77, 2), "(1977)")) text(1990, 3.5, paste(round(v98, 2), "(1998)")) text(2014, 3.1, paste(round(v21, 2), "(2021)")) #Let's get those arrows on arrows(x0 = 1981.5, y0=7.8, x1=1977.5, y1=7, length = 0.1, # length of arrowhead angle = 30, # angle of arrowhead code = 2, # 1 = head at x0,y0; 2 = head at x1,y1; 3 = both col = "black", lwd = 1) arrows(x0 = 1993.5, y0=3.7, x1=1997.5, y1=4.5, length = 0.1, # length of arrowhead angle = 30, # angle of arrowhead code = 2, # 1 = head at x0,y0; 2 = head at x1,y1; 3 = both col = "black", lwd = 1) arrows(x0 = 2017, y0=3.2, x1=2020.5, y1=4.0, length = 0.1, # length of arrowhead angle = 30, # angle of arrowhead code = 2, # 1 = head at x0,y0; 2 = head at x1,y1; 3 = both col = "black", lwd = 1) #Aha! #Figure 2 #Layer time plot(x=0, type='n', xlim=c(1976, 2021), xaxt = "n", ylim=c(0,3), yaxt = "n", xlab=" ", ylab=" ", main="Figure 2. Intolerance Toward Racists and Homosexuals, 1976-2021") axis(1, at = c(1976, 2021)) #1 says "bottom axis" axis(2, at = c(0, 1, 2, 3)) #2 says "left axis" lines(gss_collapse$year, gss_collapse$rac, lwd=2) #lines(gss_collapse$year, gss_collapse$hom, lwd=2) lines(gss_collapse$year, gss_collapse$hom, lwd=2, lty=2) #Now all the text #Nothing special to pull out here text(1980, 1.5, "Racists") text(1989, .7, "Homosexuals") #Figure 5 #Layer time plot(x=0, type='n', xlim=c(1976, 2021), xaxt = "n", ylim=c(0,1), yaxt = "n", xlab=" ", ylab=" ", main="Figure 5. A Dichotomous Measure of Tolerance and Intolerance, 1976-2021") axis(1, at = c(1976, 2021)) #1 says "bottom axis" axis(2, at = seq(0, 1, by = 0.1)) #2 says "left axis" lines(gss_collapse$year, gss_collapse$intol, lwd=2)