Learn R Programming

BSDA (version 1.2.0)

Gallup: Results of a Gallup poll on possession of marijuana as a criminal offense conducted in 1980

Description

Data for Exercise 2.76

Usage

Gallup

Arguments

Format

A data frame/tibble with 1,200 observations on two variables

demographics

a factor with levels National, Gender: Male Gender: Female, Education: College, Eduction: High School, Education: Grade School, Age: 18-24, Age: 25-29, Age: 30-49, Age: 50-older, Religion: Protestant, and Religion: Catholic

opinion

a factor with levels Criminal, Not Criminal, and No Opinion

References

Kitchens, L. J. (2003) Basic Statistics and Data Analysis. Pacific Grove, CA: Brooks/Cole, a division of Thomson Learning.

Examples

Run this code
# NOT RUN {
T1 <- xtabs(~demographics + opinion, data = Gallup)
T1
t(T1[c(2, 3), ])
barplot(t(T1[c(2, 3), ]))
barplot(t(T1[c(2, 3), ]), beside = TRUE)

# }
# NOT RUN {
library(dplyr)
library(ggplot2)
dplyr::filter(Gallup, demographics == "Gender: Male" | demographics == "Gender: Female") %>%
ggplot2::ggplot(aes(x = demographics, fill = opinion)) + 
           geom_bar() + 
           theme_bw() + 
           labs(y = "Fraction")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab