Install and load required libraries

if (!requireNamespace(“psych”, quietly = TRUE)) { install.packages(“psych”) } library(psych)

install libraries and read libraries

install.packages(“readxl”) install.packages(“dplyr”) install.packages(“ggplot2”)

library(readxl) library(dplyr) library(ggplot2)

PSY333_Final_Project_Survey_CSKKH_ReCoded <- read_excel(“C:/Users/lauren/Desktop/psy333-finalprojectinr/PSY333_Final_Project_Survey_CSKKH_ReCoded.xlsx”)

View(PSY333_Final_Project_Survey_CSKKH_ReCoded)

gaming_data <- read_excel(“C:/Users/lauren/Desktop/psy333-finalprojectinr/PSY333_Final_Project_Survey_CSKKH_ReCoded.xlsx”)

Correlation

correlation_matrix <- cor(gaming_data[c(“GamingAnger”, “GamingAnxiety”, “GamingAggression”)]) correlation_matrix

Between-subjects ANOVA

anova_result <- aov(GamingAnger ~ GamingAnxiety + GamingAggression, data = gaming_data) summary(anova_result)

View the structure of the data

str(gaming_data)

View first few rows

head(gaming_data)

View the last few rows

tail(gaming_data)

Summary statistics

summary(gaming_data)

Data Visualization

Distribution of Gaming Anger

ggplot(gaming_data, aes(x = GamingAnger)) + geom_histogram(binwidth = 1, fill = “skyblue”, color = “black”) + labs(title = “Distribution of Gaming Anger”, x = “Gaming Anger”, y = “Frequency”)

Gaming Anger vs. Gaming Anxiety

ggplot(gaming_data, aes(x = GamingAnger, y = GamingAnxiety)) + geom_point() + labs(title = “Gaming Anger vs. Gaming Anxiety”, x = “Gaming Anger”, y = “Gaming Anxiety”)

Perform factor analysis

library(psych)
fa_result <- fa(gaming_data[, c("GamingAnger", "GamingAnxiety", "GamingAggression")], nfactors = 3, rotate = "varimax")

# View factor loadings
fa_result$loadings

# Visualize factor loadings
plot(fa_result, labels = TRUE)