Download the datasets for this class:
The codebook for the survey to find the question wording for a variable
For those who prefer to work with RCloud, a project with the same materials can be accessed using the following link:
#install.packages("descr") # install if necessary
library(descr)
#install.packages("dplyr")
library(dplyr)
#install.packages("ggplot2")
library(ggplot2)
load("Datasets/gss98.RData")
names(gss98)
## [1] "X.1" "X" "SEX" "RACE" "RELIG" "FUND"
## [7] "MARITAL" "ATTEND" "PREMARSX" "XMARSEX" "HOMOSEX" "TEENSEX"
## [13] "ABANY" "CAPPUN" "GUNLAW" "GRASS" "PRAYER" "NATCITY"
## [19] "NATHEAL" "NATCRIME" "NATDRUG" "NATEDUC" "NATRACE" "NATFARE"
## [25] "NATROAD" "NATMASS" "CONCLERG" "CONEDUC" "CONFED" "CONPRESS"
## [31] "CONJUDGE" "CONLEGIS" "FECHLD" "FEHELP" "FEPRESCH" "FEFAM"
## [37] "RACDIF1" "LIVEBLKS" "MARBLK" "DISCAFF" "PARTY" "IDEOLOGY"
## [43] "AGESUM" "INCOME" "EDUC2" "REGION2" "CITY" "RURAL"
## [49] "PROT" "NEWFUND"
A CROSSTAB with ABANY
(ABORTION IF WOMAN WANTS FOR ANY REASON) as the dependent variable and SEX
as the independent variable (absolute frequencies only):
CrossTable(gss98$ABANY, gss98$SEX, prop.r = F, prop.c = F, prop.t = F, prop.chisq = F, format = "SPSS")
## Cell Contents
## |-------------------------|
## | Count |
## |-------------------------|
##
## ====================================
## gss98$SEX
## gss98$ABANY female male Total
## ------------------------------------
## No 234 145 379
## ------------------------------------
## Yes 148 97 245
## ------------------------------------
## Total 382 242 624
## ====================================
A CROSSTAB with GRASS
(SHOULD MARIJUANA BE MADE LEGAL) as the dependent variable and IDEOLOGY
as the independent variable (absolute frequencies and all three percentages are included):
CrossTable(gss98$GRASS, gss98$IDEOLOGY, prop.r = T, prop.c = T, prop.t = T, prop.chisq = F, format = "SPSS")
## Cell Contents
## |-------------------------|
## | Count |
## | Row Percent |
## | Column Percent |
## | Total Percent |
## |-------------------------|
##
## ========================================================
## gss98$IDEOLOGY
## gss98$GRASS liberal moderate conservative Total
## --------------------------------------------------------
## Should 67 54 46 167
## 40.1% 32.3% 27.5% 27.6%
## 42.9% 23.8% 20.6%
## 11.1% 8.9% 7.6%
## --------------------------------------------------------
## Should not 89 173 177 439
## 20.3% 39.4% 40.3% 72.4%
## 57.1% 76.2% 79.4%
## 14.7% 28.5% 29.2%
## --------------------------------------------------------
## Total 156 227 223 606
## 25.7% 37.5% 36.8%
## ========================================================
A CROSSTAB with CAPPUN
(FAVOR OR OPPOSE DEATH PENALTY FOR MURDER) as the dependent variable and RELIG
as the independent variable (absolute frequencies and all three percentages are included):
CrossTable(gss98$CAPPUN, gss98$RELIG, prop.r = T, prop.c = T, prop.t = T, prop.chisq = F, format = "SPSS")
## Cell Contents
## |-------------------------|
## | Count |
## | Row Percent |
## | Column Percent |
## | Total Percent |
## |-------------------------|
##
## ======================================================================
## gss98$RELIG
## gss98$CAPPUN Catholic Jewish None Other Protestant Total
## ----------------------------------------------------------------------
## Favor 170 13 88 21 355 647
## 26.3% 2.0% 13.6% 3.2% 54.9% 71.3%
## 73.9% 76.5% 67.2% 58.3% 72.0%
## 18.7% 1.4% 9.7% 2.3% 39.1%
## ----------------------------------------------------------------------
## Oppose 60 4 43 15 138 260
## 23.1% 1.5% 16.5% 5.8% 53.1% 28.7%
## 26.1% 23.5% 32.8% 41.7% 28.0%
## 6.6% 0.4% 4.7% 1.7% 15.2%
## ----------------------------------------------------------------------
## Total 230 17 131 36 493 907
## 25.4% 1.9% 14.4% 4.0% 54.4%
## ======================================================================
A CROSSTAB with CONEDUC
(CONFIDENCE IN EDUCATION) as the dependent variable and RACE
as the independent variable (absolute frequencies and all three percentages are included):
CrossTable(gss98$CONEDUC, gss98$RACE, prop.r = T, prop.c = T, prop.t = T, prop.chisq = F, format = "SPSS")
## Cell Contents
## |-------------------------|
## | Count |
## | Row Percent |
## | Column Percent |
## | Total Percent |
## |-------------------------|
##
## =================================================
## gss98$RACE
## gss98$CONEDUC Black Other White Total
## -------------------------------------------------
## great confidence 41 16 136 193
## 21.2% 8.3% 70.5% 28.6%
## 41.8% 39.0% 25.4%
## 6.1% 2.4% 20.1%
## -------------------------------------------------
## some confidence 49 22 310 381
## 12.9% 5.8% 81.4% 56.4%
## 50.0% 53.7% 57.8%
## 7.3% 3.3% 45.9%
## -------------------------------------------------
## Hardly confidnce 8 3 90 101
## 7.9% 3.0% 89.1% 15.0%
## 8.2% 7.3% 16.8%
## 1.2% 0.4% 13.3%
## -------------------------------------------------
## Total 98 41 536 675
## 14.5% 6.1% 79.4%
## =================================================
A CROSSTAB with NATEDUC
(“Are we spending too much, too little, or about the right amount on IMPROVING NATIONS EDUCATION SYSTEM”) as the dependent variable and RACE
as the independent variable (absolute frequencies and all three percentages are included):
CrossTable(gss98$NATEDUC, gss98$RACE, prop.r = T, prop.c = T, prop.t = T, prop.chisq = F, format = "SPSS")
## Cell Contents
## |-------------------------|
## | Count |
## | Row Percent |
## | Column Percent |
## | Total Percent |
## |-------------------------|
##
## ==============================================
## gss98$RACE
## gss98$NATEDUC Black Other White Total
## ----------------------------------------------
## Too little 55 21 270 346
## 15.9% 6.1% 78.0% 71.3%
## 73.3% 70.0% 71.1%
## 11.3% 4.3% 55.7%
## ----------------------------------------------
## About right 19 8 87 114
## 16.7% 7.0% 76.3% 23.5%
## 25.3% 26.7% 22.9%
## 3.9% 1.6% 17.9%
## ----------------------------------------------
## Too much 1 1 23 25
## 4.0% 4.0% 92.0% 5.2%
## 1.3% 3.3% 6.1%
## 0.2% 0.2% 4.7%
## ----------------------------------------------
## Total 75 30 380 485
## 15.5% 6.2% 78.4%
## ==============================================