INTERESTING STORY = Is there a relationship between gender identity and experiencing hunger on campus?

Chapter 1: Exploring Categorical Data

Import data

## Load dplyr package
library(dplyr) #for use of dplyr functions such as glimpse(), mutate(), and filter()
library(ggplot2) #for use of ggplot2 functions such ggplot()

# Import data
hunger <- read.csv("/resources/data/hunger.csv") 

# Convert data to tbl_df
hunger <- tbl_df(hunger)
str(hunger)
## Classes 'tbl_df', 'tbl' and 'data.frame':    655 obs. of  53 variables:
##  $ StartDate            : Factor w/ 501 levels "10/10/2017 11:16",..: 501 271 371 372 372 372 371 372 372 372 ...
##  $ EndDate              : Factor w/ 506 levels "10/10/2017 10:17",..: 506 276 375 375 375 375 375 376 376 376 ...
##  $ Status               : Factor w/ 3 levels "IP Address","Spam",..: 3 1 1 1 1 1 1 1 1 1 ...
##  $ IPAddress            : Factor w/ 227 levels "100.40.17.133",..: NA 38 38 22 221 33 40 77 40 39 ...
##  $ Progress             : int  100 100 100 100 100 100 100 100 100 100 ...
##  $ Duration..in.seconds.: int  57 683 109 94 101 66 129 80 100 88 ...
##  $ Finished             : logi  TRUE TRUE TRUE TRUE TRUE TRUE ...
##  $ RecordedDate         : Factor w/ 520 levels "10/10/2017 10:17",..: 520 317 397 397 397 397 398 398 398 398 ...
##  $ ResponseId           : Factor w/ 655 levels "R_086f1AK7KVS77pv",..: 576 495 122 642 440 618 379 280 159 589 ...
##  $ RecipientLastName    : logi  NA NA NA NA NA NA ...
##  $ RecipientFirstName   : logi  NA NA NA NA NA NA ...
##  $ RecipientEmail       : logi  NA NA NA NA NA NA ...
##  $ ExternalReference    : logi  NA NA NA NA NA NA ...
##  $ LocationLatitude     : num  43.7 43.7 43.7 43.7 43.7 ...
##  $ LocationLongitude    : num  -71.7 -71.7 -71.7 -71.7 -71.7 ...
##  $ DistributionChannel  : Factor w/ 2 levels "anonymous","preview": 2 1 1 1 1 1 1 1 1 1 ...
##  $ UserLanguage         : Factor w/ 1 level "EN": 1 1 1 1 1 1 1 1 1 1 ...
##  $ Q1                   : Factor w/ 2 levels "No","Yes": NA 2 2 2 2 2 2 2 2 2 ...
##  $ Q2                   : Factor w/ 8 levels "18-24 years old",..: NA 1 1 1 1 4 1 3 1 1 ...
##  $ Q3                   : Factor w/ 5 levels "Female","Male",..: NA 1 2 1 1 1 1 1 1 1 ...
##  $ Q3_4_TEXT            : Factor w/ 3 levels "Androgyne Woman",..: NA NA NA NA NA NA NA NA NA NA ...
##  $ Q4                   : Factor w/ 11 levels "American Indian or Alaska Native",..: NA 6 6 6 6 6 6 6 8 6 ...
##  $ Q26                  : Factor w/ 19 levels "Community Member / Visitor to PSU",..: NA 6 6 6 6 2 6 19 6 6 ...
##  $ Q27                  : Factor w/ 9 levels "Associate degree",..: NA 4 4 4 7 3 7 1 7 7 ...
##  $ Q5                   : Factor w/ 4 levels "Associate degree",..: NA 4 4 4 4 NA 4 NA 4 4 ...
##  $ Q6                   : Factor w/ 2 levels "No","Yes": NA 1 1 1 1 NA 1 NA 1 1 ...
##  $ Q7                   : Factor w/ 3 levels "150 Block + $100 flex cash",..: NA NA NA NA NA NA NA NA NA NA ...
##  $ Q8                   : Factor w/ 5 levels "Do not care for food served in dining halls",..: NA NA NA NA NA NA NA NA NA NA ...
##  $ Q8_5_TEXT            : Factor w/ 4 levels "I take classes on-line, and do not go to campus, so I do not need one.",..: NA NA NA NA NA NA NA NA NA NA ...
##  $ Q9                   : Factor w/ 3 levels "Don't know","No",..: NA 3 2 2 2 2 2 2 2 2 ...
##  $ Q10                  : Factor w/ 3 levels "Don't know","No",..: NA 3 2 NA 2 NA 2 NA 2 2 ...
##  $ Q11                  : Factor w/ 3 levels "I don't know if I qualify",..: NA 1 3 2 1 2 2 3 1 2 ...
##  $ Q12                  : Factor w/ 3 levels "I don't know",..: NA 2 2 2 2 2 2 3 2 2 ...
##  $ Q13                  : Factor w/ 15 levels "Food pantry of campus",..: NA 8 8 8 8 8 8 8 8 8 ...
##  $ Q13_5_TEXT           : Factor w/ 9 levels "A local church gave me Hannaford gift cards",..: NA NA NA NA NA NA NA NA NA NA ...
##  $ Q15                  : Factor w/ 4 levels "I don't know",..: NA 3 3 4 3 3 3 4 4 3 ...
##  $ Q16                  : Factor w/ 2 levels "No","Yes": NA NA NA NA NA NA NA NA NA NA ...
##  $ Q18                  : logi  NA NA NA NA NA NA ...
##  $ Q19                  : logi  NA NA NA NA NA NA ...
##  $ Q22                  : Factor w/ 2 levels "No","Yes": NA 1 1 1 1 1 1 1 1 1 ...
##  $ Q33                  : Factor w/ 4 levels "Both","Neither",..: NA NA NA NA NA NA NA NA NA NA ...
##  $ Q31                  : Factor w/ 2 levels "No","Yes": NA 1 1 1 1 1 1 1 1 1 ...
##  $ Q32_1                : int  NA NA NA NA 0 NA 0 NA NA NA ...
##  $ Q34_1                : int  NA NA NA NA NA NA NA NA NA NA ...
##  $ Q33.1                : Factor w/ 3 levels "No","Sometimes",..: NA 3 3 3 3 3 2 3 3 3 ...
##  $ Q28                  : Factor w/ 2 levels "No","Yes": NA 1 2 1 2 2 1 2 2 2 ...
##  $ Q29                  : Factor w/ 3 levels "Maybe","No","Yes": NA 1 3 1 3 3 2 3 3 2 ...
##  $ Q30                  : Factor w/ 2 levels "No","Yes": NA 1 2 1 2 2 1 2 2 1 ...
##  $ Q38                  : Factor w/ 2 levels "No","Yes": NA 1 1 1 1 1 1 1 1 1 ...
##  $ Q35                  : Factor w/ 18 levels "Amount of food received",..: NA NA NA NA NA NA NA NA NA NA ...
##  $ Q35_7_TEXT           : Factor w/ 1 level "Overall, great service and volunteers": NA NA NA NA NA NA NA NA NA NA ...
##  $ Q36                  : Factor w/ 19 levels "Amount of food received,Nutritional value of food received",..: NA NA NA NA NA NA NA NA NA NA ...
##  $ Q36_7_TEXT           : Factor w/ 3 levels "its fine","More gluten free options",..: NA NA NA NA NA NA NA NA NA NA ...

Contingency table review

# Check the levels of hunger
levels(hunger$Q22)
## [1] "No"  "Yes"

Barcharts

# Create plot of Have you experienced hunger in the past year?
# Remove gender level
hunger <- hunger %>%
  filter(!(Q22 %in% c(NA))) %>%
  droplevels()

ggplot(hunger, aes(x = Q22)) + 
  geom_bar() + xlab("Have you experienced hunger in the past year?")

Interpretation Roughly 1 in 5 students experiences hunger on campus

# Create plot of In the past year, did you reduce the size of your meals because you could not afford food?
# Remove gender level
hunger <- hunger %>%
  filter(!(Q31 %in% c(NA))) %>%
  droplevels()

ggplot(hunger, aes(x = Q31)) + 
  geom_bar() + xlab("Have you reduced the size of your meals because you can not afford food?")

# Remove gender level
hunger <- hunger %>%
  filter(!(Q33 %in% c(NA))) %>%
  droplevels()
ggplot(hunger, aes(x = Q33)) + 
  geom_bar() + xlab("The hunger I experienced was:")

Interpretation The majority of students that experience hunger do so during the school semester.

# Create side-by-side barchart of gender by alignment
ggplot(hunger, aes(x = Q3, fill = Q22)) + 
  geom_bar(position = "dodge") #position = "dodge", to have a side-by-side (i.e. not stacked) barchart.

Interpretation Based upon this barchart, we can conlcude that females are more likely to experience hunger than males.