Data Intake and Summary

Resting measurements of the body temperature and heart rate of 65 men and 65 women were randomly taken. We find this data in the provided normtemp.csv file. To begin, we must read the csv file into R.

# Load Data from provided URL
url <- "https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv"
dat <- read.csv(url)
#dat$Sex <- as.factor(dat$Sex)

Once I have taken the data in, I will isolate the male and female data.

maleHR <- dat$Beats[dat$Sex==1]
femaleHR <- dat$Beats[dat$Sex==2]
maleTEMP <- dat$Temp[dat$Sex==1]
femaleTEMP <- dat$Temp[dat$Sex==2]

From there we can now look at a summary of the statistics of the data:

cat("A summary of the male heart rate data:\n")
## A summary of the male heart rate data:
summary(maleHR)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   58.00   70.00   73.00   73.37   78.00   86.00
cat("A summary of the male temperature data:\n")
## A summary of the male temperature data:
summary(maleTEMP)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    96.3    97.6    98.1    98.1    98.6    99.5
cat("A summary of the female heart rate data:\n")
## A summary of the female heart rate data:
summary(femaleHR)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   57.00   68.00   76.00   74.15   80.00   89.00
cat("A summary of the female temperature data:\n")
## A summary of the female temperature data:
summary(femaleTEMP)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   96.40   98.00   98.40   98.39   98.80  100.80
cat("The standard deviation of the the male heart rate is ",sd(maleHR),".\n")
## The standard deviation of the the male heart rate is  5.875184 .
cat("The standard deviation of the the female heart rate is ",sd(femaleHR),".\n")
## The standard deviation of the the female heart rate is  8.105227 .
cat("The standard deviation of the the male temperature is ",sd(maleTEMP),".\n")
## The standard deviation of the the male temperature is  0.6987558 .
cat("The standard deviation of the the female temperature is ",sd(femaleTEMP),".\n")
## The standard deviation of the the female temperature is  0.7434878 .

From this data, we can see that the females had the lowest heartrate, but the sample mean and max of the female’s heart rate exceeded that of the male samples. While males, had the lowest temperatures, the female samples mean and max temp again exceeded the male samples.

The females were found to have a greater standard deviation than males in both heart rate and temperature.

Histograms

hist(maleHR, 
     main = "Histogram of Male Heart Rate",
     xlab = "Heart Rate (BPM)",
     col = "Blue"
     )

As the previous summary showed, the median male heart rate falls between 70-75 bpm.

hist(maleTEMP,
     main = "Histogram of Male Temperature",
     xlab = "Temperature (°F)",
     col = "Blue"
     )

hist(femaleHR, 
     main = "Histogram of Female Heart Rate",
     xlab = "Heart Rate (BPM)",
     col = "Pink"
     )

As the previous summary showed, the median female heart rate falls between 75-80 bpm.

hist(femaleTEMP,
     main = "Histogram of female Temperature",
     xlab = "Temperature (°F)",
     col = "Pink"
     )

Probability Plots

qqnorm(maleHR,main = "Normal Q-Q plot Heart Rate (Males)")
qqline(maleHR, col="blue")

The Q-Q plot above shows the normal probability of the male heart rate data. The data looks to be normal and follows the line.

qqnorm(maleTEMP,main = "Normal Q-Q plot Temperature (Males)")
qqline(maleHR, col="blue")

qqnorm(femaleHR,main = "Normal Q-Q plot Heart Rate (Females)")
qqline(femaleHR, col="pink")

The Q-Q plot above shows the normal probability of the female heart rate data. The data looks to be normal and follows the line.

qqnorm(femaleTEMP,main = "Normal Q-Q plot Temperature (Females)")
qqline(femaleHR, col="pink")

Box Plot

boxplot(maleHR,femaleHR,
        names = c("Male","Females"),
        col = c("blue","pink"),
        main = "Resting Heart Rate Comparison",
        ylab = "Heart Rate (BPM)"
        )

From the box plot above, we can see that the median heart rate for females is higher than that of males. We can also see that the upper and lower quartiles and min and max heart rate data are greater than those of males. This correlates properly with the previous data summary.

All Code

knitr::opts_chunk$set(echo=TRUE, warning=FALSE, message=FALSE)
# Load Data from provided URL
url <- "https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv"
dat <- read.csv(url)
#dat$Sex <- as.factor(dat$Sex)
maleHR <- dat$Beats[dat$Sex==1]
femaleHR <- dat$Beats[dat$Sex==2]
maleTEMP <- dat$Temp[dat$Sex==1]
femaleTEMP <- dat$Temp[dat$Sex==2]
cat("A summary of the male heart rate data:\n")
summary(maleHR)
cat("A summary of the male temperature data:\n")
summary(maleTEMP)
cat("A summary of the female heart rate data:\n")
summary(femaleHR)
cat("A summary of the female temperature data:\n")
summary(femaleTEMP)
cat("The standard deviation of the the male heart rate is ",sd(maleHR),".\n")
cat("The standard deviation of the the female heart rate is ",sd(femaleHR),".\n")
cat("The standard deviation of the the male temperature is ",sd(maleTEMP),".\n")
cat("The standard deviation of the the female temperature is ",sd(femaleTEMP),".\n")
hist(maleHR, 
     main = "Histogram of Male Heart Rate",
     xlab = "Heart Rate (BPM)",
     col = "Blue"
     )
hist(maleTEMP,
     main = "Histogram of Male Temperature",
     xlab = "Temperature (°F)",
     col = "Blue"
     )
hist(femaleHR, 
     main = "Histogram of Female Heart Rate",
     xlab = "Heart Rate (BPM)",
     col = "Pink"
     )
hist(femaleTEMP,
     main = "Histogram of female Temperature",
     xlab = "Temperature (°F)",
     col = "Pink"
     )
qqnorm(maleHR,main = "Normal Q-Q plot Heart Rate (Males)")
qqline(maleHR, col="blue")

qqnorm(maleTEMP,main = "Normal Q-Q plot Temperature (Males)")
qqline(maleHR, col="blue")
qqnorm(femaleHR,main = "Normal Q-Q plot Heart Rate (Females)")
qqline(femaleHR, col="pink")
qqnorm(femaleTEMP,main = "Normal Q-Q plot Temperature (Females)")
qqline(femaleHR, col="pink")
boxplot(maleHR,femaleHR,
        names = c("Male","Females"),
        col = c("blue","pink"),
        main = "Resting Heart Rate Comparison",
        ylab = "Heart Rate (BPM)"
        )