```{r}if (!require(“tidyverse”))} install.packages(“tidyverse”) library(tidyverse)
mydata <- read.csv(“https://raw.githubusercontent.com/drkblake/Data/main/DormTemps.csv”) head(mydata, 10)
mydata\(V1 <- mydata\)RoomTemp test_value = 70.0
ggplot(mydata, aes(x = V1)) + geom_histogram(color = “black”, fill = “#1f78b4”) + geom_vline(aes(xintercept = mean(V1)))
mydata %>% select(V1) %>% summarise( count = n(), mean =
mean(V1, na.rm = TRUE), sd = sd(V1, na.rm = TRUE), min = min(V1, na.rm =
TRUE), max = max(V1, na.rm = TRUE), W Statistic =
shapiro.test(V1)\(statistic, `p-value` =
shapiro.test(V1)\)p.value)
t.test(mydata$V1, mu = test_value)
# Conclusion:
The average is at 62.7 degrees and that is lower than the schools stated average of 70. This is a huge significant change.
# Task 2:
```r
if (!require("tidyverse"))
install.packages("tidyverse")
## Loading required package: tidyverse
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
if (!require("gmodels"))
install.packages("gmodels")
## Loading required package: gmodels
library(gmodels)
library(tidyverse)
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
mydata$V1 <- mydata$Range
ggplot(mydata, aes(x = V1)) +
geom_bar(fill = "royalblue")
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 |
## |--------------|--------------|
##
##
##
##
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 < 2.2e-16
The data shows that only 14% are in range and then 85% are out of range. This shows the university’s claim is incorrect