# This code will load the R packages we will use
suppressPackageStartupMessages({
library(mosaic)
library(supernova)
library(Lock5withR)})
font_size = function (size) {
theme(text = element_text(size = size))}
# We have loaded the csv link into an object called linktocsv
# Use that object to write some code to get this data into a data frame called respectstudy
linktocsv <- "https://docs.google.com/spreadsheets/d/e/2PACX-1vShHDu7P5XnUWo_xBtB67I00R-TTCyB73GyILmjlMq3LGM-kHFg-rIBQwB4upLOU7mTXG6fg8QxTLhB/pub?gid=191363782&single=true&output=csv"
# Run some code to check out the data. What are the cases?
# Write some code here
# Write some code here
# Feel free to copy and paste your visualization from above here.
# Hint: You can pipe on a line to any faceted histograms, boxplot, jitter, etc.
# Try functions like gf_vline (for vertical lines) or gf_hline (for horizontal)
# Write code here.
# Here's a set of visualizations where the outcome gets shuffled
# and the empty model is fit from the shuffled data.
# Run it a few times to see if the empty model changes.
# this creates the outcome variable
respectstudy$vegeaten <- respectstudy$spoon2_before - respectstudy$spoon2_after
# this shuffles the outcome
respectstudy$shuffled_vegeaten <- shuffle(respectstudy$vegeaten)
# gets the favstats of the outcome
shuff.stats <- favstats(~ shuffled_vegeaten, data = respectstudy)
# makes a histogram of the shuffled data
gf_histogram(~ shuffled_vegeaten, data = respectstudy, fill = "purple4", color = "purple3") %>%
gf_facet_grid(respect_condition ~ .) %>%
gf_vline(xintercept = ~mean, data = shuff.stats) %>%
gf_labs(title = "vegeaten has been shuffled")
# makes a jitter plot of same data
gf_jitter(shuffled_vegeaten ~ respect_condition, data = respectstudy, size = 5, alpha = .2, height = 0, color = "purple") %>%
gf_hline(yintercept = ~mean, data = shuff.stats) %>%
gf_labs(title = "vegeaten has been shuffled")