Tutorial One

1. Setup chunk to load R packages

#this basic setup chunk came is going to load pacman first, which will allow me to load the other functions I need, then launch them easily.

library(pacman) #loading pacman

p_load(tidyverse, psych, readxl, haven, janitor, knitr, grid) #loading packages

2. Visualising Data

Tables

This simple table shows the relationship between diet and climate support status with no additional details.

tut_1_data <- read_xlsx("chi_tut_data.xlsx") 
  #tut_1_data #testing that the data prints

vis_1 <- table(tut_1_data$climate_support, tut_1_data$diet_types)
  vis_1
##                   
##                    meat_eater vegan vegetarian
##   does_not_support         84    27         51
##   support                  26    77         59

This second table uses the first as a base, and adds a heading for clarity.

vis_2 <- kable(vis_1, caption = "Frequency Table for Diet and Climate Support Status")
  vis_2
Frequency Table for Diet and Climate Support Status
meat_eater vegan vegetarian
does_not_support 84 27 51
support 26 77 59

The two tables below analyse one variable at a time, taking a look at the proportions or percentages into which each variable is split.

vis_3 <- tabyl(tut_1_data, diet_types)
  vis_3
vis_4 <- tabyl(tut_1_data, climate_support)
  vis_4

Bar Plots

Code chunk for Bar Plot

barplot(vis_1, 
        beside = TRUE, 
        legend = TRUE,
        col = c("pink", "lightgreen"),
        xlab = "Diet", 
        ylab = "Climate Support Status",
        main = "Barplot of Diet and Climate Support Status")

This Bar Plot uses data from the first table to show the relationship between the participants’ diet choices, and their status with regard to climate activism.

There are 110 meat-eaters, 110 vegetatians and 104 vegans participating in the study. The participants are split exactly in half in terms of support of climate activism, with 162 participants supporting it and 162 not supporting it.

We can see here, and with the help of vis_3 and vis_4, that meat eaters in our sample are more likely to be unsupportive of climate activism than they are likely to support it. Vegetarianism leans slightly toward climate activism support, but there is no clear relationship between vegetarianism and climate activism. Lastly, a large proportion of vegans support climate activism, with a small proportion of participants deviating from this.

3. Chi-squared test

chisq_GOF_test <- chisq.test(vis_1)
  chisq_GOF_test
## 
##  Pearson's Chi-squared test
## 
## data:  vis_1
## X-squared = 55.202, df = 2, p-value = 1.03e-12

4. Residual Analysis

Analysis

5. Interpretation of Chi-squared test results

Analysis

6. Report

This will be converted to a PDF and submitted to Amathuba for marking.