library(tidyverse)The Impact of Gaming Hours on Learning Performance
1 Introduction
Video games are often viewed as entertainment, but some researchers suggest that gaming may improve cognitive abilities such as attention, memory, and problem-solving skills.
This study investigates whether the amount of time spent playing video games is associated with learning performance.
1.1 Research Question
Does the number of gaming hours per week affect learning performance?
1.2 Hypothesis
1.2.1 Null Hypothesis (H0)
Gaming hours have no significant effect on learning performance.
1.2.2 Alternative Hypothesis (H1)
Gaming hours positively affect learning performance.
2 Load Required Libraries
3 Data Import
In a real research project, data would be collected from students through surveys and learning assessments.
For demonstration purposes, we create a sample dataset and save it as a CSV file.
gaming_learning_demo <- data.frame(
student_id = 1:12,
gaming_hours = c(2,4,5,7,8,10,12,14,15,18,20,22),
learning_score = c(60,64,66,70,73,77,80,84,86,89,91,94)
)
write.csv(
gaming_learning_demo,
"gaming_learning.csv",
row.names = FALSE
)Import the dataset.
gaming_learning <- read.csv("gaming_learning.csv")
head(gaming_learning) student_id gaming_hours learning_score
1 1 2 60
2 2 4 64
3 3 5 66
4 4 7 70
5 5 8 73
6 6 10 77
4 Data Cleaning (Tidying)
Inspect the structure of the dataset.
str(gaming_learning)'data.frame': 12 obs. of 3 variables:
$ student_id : int 1 2 3 4 5 6 7 8 9 10 ...
$ gaming_hours : int 2 4 5 7 8 10 12 14 15 18 ...
$ learning_score: int 60 64 66 70 73 77 80 84 86 89 ...
Check for missing values.
colSums(is.na(gaming_learning)) student_id gaming_hours learning_score
0 0 0
Remove missing values if necessary.
gaming_learning <- gaming_learning %>%
drop_na()Display summary statistics.
summary(gaming_learning) student_id gaming_hours learning_score
Min. : 1.00 Min. : 2.00 Min. :60.00
1st Qu.: 3.75 1st Qu.: 6.50 1st Qu.:69.00
Median : 6.50 Median :11.00 Median :78.50
Mean : 6.50 Mean :11.42 Mean :77.83
3rd Qu.: 9.25 3rd Qu.:15.75 3rd Qu.:86.75
Max. :12.00 Max. :22.00 Max. :94.00
5 Data Transformation
Create a learning performance category.
gaming_learning <- gaming_learning %>%
mutate(
performance_level = if_else(
learning_score >= 80,
"High",
"Low"
)
)
head(gaming_learning) student_id gaming_hours learning_score performance_level
1 1 2 60 Low
2 2 4 64 Low
3 3 5 66 Low
4 4 7 70 Low
5 5 8 73 Low
6 6 10 77 Low
Count students in each performance category.
gaming_learning %>%
count(performance_level) performance_level n
1 High 6
2 Low 6
6 Data Visualization
6.1 Scatter Plot
Visualize the relationship between gaming hours and learning score.
ggplot(
gaming_learning,
aes(
x = gaming_hours,
y = learning_score
)
) +
geom_point(size = 3) +
labs(
title = "Gaming Hours and Learning Performance",
x = "Gaming Hours per Week",
y = "Learning Score"
)6.2 Scatter Plot with Regression Line
ggplot(
gaming_learning,
aes(
x = gaming_hours,
y = learning_score
)
) +
geom_point(size = 3) +
geom_smooth(
method = "lm",
se = TRUE
) +
labs(
title = "Relationship Between Gaming Hours and Learning Score",
x = "Gaming Hours per Week",
y = "Learning Score"
)7 Modeling
7.1 Simple Linear Regression
Fit a simple linear regression model.
model <- lm(
learning_score ~ gaming_hours,
data = gaming_learning
)
model
Call:
lm(formula = learning_score ~ gaming_hours, data = gaming_learning)
Coefficients:
(Intercept) gaming_hours
58.203 1.719
7.2 Model Summary
summary(model)
Call:
lm(formula = learning_score ~ gaming_hours, data = gaming_learning)
Residuals:
Min 1Q Median 3Q Max
-2.0307 -1.2086 -0.1961 1.2734 2.0053
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 58.20311 0.91795 63.41 2.32e-14 ***
gaming_hours 1.71944 0.07056 24.37 3.09e-10 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.525 on 10 degrees of freedom
Multiple R-squared: 0.9834, Adjusted R-squared: 0.9818
F-statistic: 593.8 on 1 and 10 DF, p-value: 3.087e-10
8 Interpretation of Results
The coefficient for gaming_hours shows the expected change in learning score for each additional hour of gaming per week.
A positive coefficient suggests that students who spend more time gaming tend to achieve higher learning scores.
The p-value helps determine whether the relationship is statistically significant.
9 Conclusion
This analysis demonstrates the complete data science workflow using a gaming-related research topic.
The workflow includes:
- Research Design
- Data Import
- Data Cleaning
- Data Transformation
- Data Visualization
- Modeling
- Communication of Results
The simple linear regression model helps determine whether gaming hours are associated with learning performance.
10 Communication (Rendering Output)
To generate the final report:
- Save this file as
gaming_learning_workflow.qmd - Open it in RStudio
- Click Render
- Quarto will execute all code chunks
- An HTML report will be generated automatically
The rendered report will contain:
- Research Question
- Hypothesis
- Imported Data
- Summary Statistics
- Scatter Plots
- Regression Results
- Interpretation
- Conclusion