Housing Hall HVAC Unit Tests

Attached is the code used for Dr. Blake’s Week 12 Lab of his JOUR 3841 Spring 2024 Course at MTSU. After each test in the code is a comment block briefly explaining the findings of these tests, labeled as “1” and “2” for their correlating portion of the lab assignment.

# Installing required packages
if (!require("tidyverse"))
  install.packages("tidyverse")
if (!require("gmodels"))
  install.packages("gmodels")
library(gmodels)
library(tidyverse)

options(scipen = 9999)

# Read the data
mydata <- read.csv("https://raw.githubusercontent.com/drkblake/Data/main/DormTemps.csv")
head(mydata, 10)
##    DormID RoomTemp        Range
## 1       1     61.0 Out of range
## 2       2     72.9     In range
## 3       3     67.0     In range
## 4       4     64.2 Out of range
## 5       5     62.2 Out of range
## 6       6     70.4     In range
## 7       7     62.7 Out of range
## 8       8     62.3 Out of range
## 9       9     62.2 Out of range
## 10     10     64.2 Out of range
# Specify V1
mydata$V1 <- mydata$Range #Edit YOURDVNAME

# Look at V1
ggplot(mydata, aes(x = V1)) +
  geom_bar(fill = "royalblue")

# Make the crosstab table
CrossTable(
  mydata$V1,
  prop.chisq = FALSE,
  prop.t = FALSE,
  prop.r = FALSE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |-------------------------|
## 
##  
## Total Observations in Table:  175 
## 
##  
##              |     In range | Out of range | 
##              |--------------|--------------|
##              |           26 |          149 | 
##              |        0.149 |        0.851 | 
##              |--------------|--------------|
## 
## 
## 
## 
# Run the chi-squared test
test <- chisq.test(table(mydata$V1))
test
## 
##  Chi-squared test for given probabilities
## 
## data:  table(mydata$V1)
## X-squared = 86.451, df = 1, p-value < 0.00000000000000022
# 1. The extremely low p-value indicates a significant difference between the 
# actual average and the university's claim. 

test2 <- chisq.test(table(mydata$V1),
                   p = c(.60,.40))
test2
## 
##  Chi-squared test for given probabilities
## 
## data:  table(mydata$V1)
## X-squared = 148.6, df = 1, p-value < 0.00000000000000022
# 2. This p-value is also listed as exceptionally small.
# Therefore, there is a significant difference between the actual average and
# the university's claim.