One-Sample Right-Tailed t-Test
# Goal:
# Test whether the population mean height is greater than 60.
#
# Null Hypothesis (H0): mu <= 60
# Alternative Hypothesis (H1): mu > 60
#
# Data Source:
# Kaggle – High School Heights Dataset (hs_heights.csv)
# ============================================================
# ------------------------------------------------------------
# 1) Load the dataset
# ------------------------------------------------------------
# Read CSV file downloaded from Kaggle
data <- read.csv("hs_heights.csv")
# Check structure to confirm column name and data type
str(data)
## 'data.frame': 1000 obs. of 1 variable:
## $ heights: num 61.5 63.5 64 64.7 63.9 ...
# ------------------------------------------------------------
# 2) Select the height column
# (Column name confirmed as "heights")
# ------------------------------------------------------------
heights <- data$heights
# ------------------------------------------------------------
# 3) Perform One-Sample Right-Tailed t-Test
# ------------------------------------------------------------
test_result <- t.test(heights,
mu = 60,
alternative = "greater")
test_result
##
## One Sample t-test
##
## data: heights
## t = 39.868, df = 999, p-value < 2.2e-16
## alternative hypothesis: true mean is greater than 60
## 95 percent confidence interval:
## 64.38198 Inf
## sample estimates:
## mean of x
## 64.57073
# ------------------------------------------------------------
# 4) Visualization
# ------------------------------------------------------------
# Create histogram of height distribution
hist(heights,
main = "Height Distribution",
xlab = "Height (inches)",
col = "lightblue",
border = "white")
# Add vertical red line at hypothesized mean (60)
abline(v = 60, col = "red", lwd = 2)

# ------------------------------------------------------------
# Interpretation
# ------------------------------------------------------------
# The sample mean is approximately 64.57 inches.
# The p-value is extremely small (p < 0.05).
# Therefore, we reject the null hypothesis.
# There is strong statistical evidence that the mean height
# is greater than 60 inches.