Checklist completed by: Fizza Zaheer
Testing with sample data
# Create simple data
test_data <- data.frame(
ID = 1:5,
Value = c(10, 20, 15, 25, 30)
)
# Show it
print("Test Data Created:")
## [1] "Test Data Created:"
print(test_data)
## ID Value
## 1 1 10
## 2 2 20
## 3 3 15
## 4 4 25
## 5 5 30
# Calculate mean
mean_value <- mean(test_data$Value)
# Calculate sum
total <- sum(test_data$Value)
cat("Mean:", mean_value, "\n")
## Mean: 20
cat("Total:", total, "\n")
## Total: 100
# Create a bar plot
barplot(test_data$Value,
names.arg = test_data$ID,
main = "Sample Values by ID",
xlab = "ID",
ylab = "Value",
col = "skyblue")
# Create data
set.seed(123)
study_data <- data.frame(
Hours = sample(1:20, 30, replace = TRUE),
Grade = sample(60:90, 30, replace = TRUE)
)
study_data$Score <- 50 + 2*study_data$Hours + 0.5*study_data$Grade + rnorm(30, 0, 5)
print("Data created successfully ✓")
## [1] "Data created successfully ✓"
# Fit model
model <- lm(Score ~ Hours + Grade, data = study_data)
print("Regression model:")
## [1] "Regression model:"
print(summary(model))
##
## Call:
## lm(formula = Score ~ Hours + Grade, data = study_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -7.5136 -3.6777 0.4743 2.8690 9.7157
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 45.4707 8.1510 5.579 6.47e-06 ***
## Hours 2.0517 0.1896 10.824 2.53e-11 ***
## Grade 0.5618 0.1030 5.454 9.02e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 5.16 on 27 degrees of freedom
## Multiple R-squared: 0.8473, Adjusted R-squared: 0.836
## F-statistic: 74.91 on 2 and 27 DF, p-value: 9.585e-12
cat("All checks complete ✓\n")
## All checks complete ✓