This is what I have so far for my code
Load necessary libraries
library(tidyverse)
library(ggplot2)
library(broom)
data <- read.csv("eorgan.csv")
This will read the data
head(data)
This will display the top of the data table
tidy_data <- data %>%
gather(key = "Tempature", value = "Cortisol Levels", -Participant_ID) %>%
mutate(Tempature = factor(Tempature, levels = c("Hot", "Cold")))
This will tidy the data
head(tidy_data)
this will display the top of the tidy data table
ggplot(tidy_data, aes(x = Tempature, y = Cortisol_Levels, fill = Tempature)) +
geom_boxplot() +
labs(title = "Boxplot of Cortisol Before and After",
x = "Tempature of Shower",
y = "Cortisol Levels") +
theme_minimal()
EDA: Boxplot for each time point
tidy_data %>%
filter(Tempature == "Cold") %>%
left_join(
tidy_data %>%
filter(Tempature == "Hot") %>%
select(Participant_ID, Hot = Temperature),
by = "Participant_ID"
) %>%
mutate(Difference = Cold - Hot) %>%
ggplot(aes(x = Difference)) +
geom_histogram(binwidth = 1, fill = "skyblue", color = "black") +
labs(title = "Histogram of Temperature Differences",
x = "Difference (Cold - Hot)",
y = "Frequency") +
theme_minimal()
EDA: Histogram of differences
shapiro_test <- tidy_data %>%
filter(Tempature == "Cold") %>%
left_join(
tidy_data %>%
filter(Tempature == "Hot") %>%
select(Participant_ID, Hot = Temperature),
by = "Participant_ID"
) %>%
summarise(shapiro_test = shapiro.test(Cold - Hot)$p.value)
Normality test for differences
print("Shapiro-Wilk Test for Normality of Differences:")
print(shapiro_test)
Print the result of the normality test
levene_test <- tidy_data %>%
group_by(TimePoint) %>%
summarise(levene_test = leveneTest(MentalHealth ~ TimePoint, data = .)$p.value)
Homogeneity of variances test
print("Levene's Test for Homogeneity of Variances:")
print(levene_test)
Print the result of the homogeneity of variances test
Everytime I run my code this is what it tells me
Error in make_ansi_style(x[["color"]]) : Unknown style specification: br_magenta
Error in head(tidy_data) : object 'tidy_data' not found Error in ggplot(tidy_data, aes(x = Tempature, y = Cortisol_Levels, fill = Tempature)) : object 'tidy_data' not found [1] "Shapiro-Wilk Test for Normality of Differences:" Error in print(shapiro_test) : object 'shapiro_test' not found [1] "Levene's Test for Homogeneity of Variances:" Error in print(levene_test) : object 'levene_test' not found
[image] Show Traceback
Error in filter(., Tempature == "Cold") : object 'tidy_data' not found
[image] Show Traceback
Error in filter(., Tempature == "Cold") : object 'tidy_data' not found
[image] Show Traceback
Error in group_by(., TimePoint) : object 'tidy_data' not found
Any help I can get is much appreciated, this is due in two days, and I'm freaking out. Code bits work just fine. I can't figure out why it won't stop telling me there are errors.