This report captures work done for the 2nd flipped assignment, studying male and female resting heart rates. R code along with the results are provided. It was a pleasure for Team 4 to complete this assignment.

Reading the Data and Creating the Dataframe

The following is a summary of the descriptive statistics of resting heart rates for both males and females.

# setup Libraries
library(knitr)
# read in file
d<- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv", sep=",", na.strings = c("","."))
# clean up first col name and as.factor for sex
names(d)[1] <- "Temp"
d$Sex<- as.factor(d$Sex)
# setup data frame
dataTable<- data.frame(matrix(NA,2,6))
rownames(dataTable)<- c('Male','Female')
colnames(dataTable)<- c('min','max','mean','sd','median','quantile')



# males = 1, females = 2
# men
dataTable$min[1] <- min(d$Beats[d$Sex == 1])
dataTable$max[1] <- max(d$Beats[d$Sex == 1])
dataTable$mean[1] <- mean(d$Beats[d$Sex == 1])
dataTable$sd[1] <- sd(d$Beats[d$Sex == 1])
dataTable$median[1] <- median(d$Beats[d$Sex == 1])
dataTable$quantile[1] <- list(as.vector(quantile(d$Beats[d$Sex == 1])))
# women
dataTable$min[2] <- min(d$Beats[d$Sex == 2])
dataTable$max[2] <- max(d$Beats[d$Sex == 2])
dataTable$mean[2] <- mean(d$Beats[d$Sex == 2])
dataTable$sd[2] <- sd(d$Beats[d$Sex == 2])
dataTable$median[2] <- median(d$Beats[d$Sex == 2])
dataTable$quantile[2] <- list(as.vector(quantile(d$Beats[d$Sex == 2])))



## format Table
# Mean and SD to 2 decimal places
dataTable$mean <- as.numeric(format(round(dataTable$mean,2), nsmall = 2))
dataTable$sd <- as.numeric(format(round(dataTable$sd,2), nsmall = 2))
kable(dataTable,caption = "Statistical Table of Male and Female")
Statistical Table of Male and Female
min max mean sd median quantile
Male 58 86 73.37 5.88 73 58, 70, 73, 78, 86
Female 57 89 74.15 8.11 76 57, 68, 76, 80, 89

With a sample size of 65 for each sex, the average resting heart rate of males is about 1% lower than that of females. The resting heart rate of males has a slightly smaller range (58 BPM - 86 BPM) than that of females (57 BPM - 89 BPM). The resting heart rate standard deviation of males is about 38% lower than that of females. The male resting heart rates are pretty well centralized around the mean of 73 BPM. The females resting heart rates are not represented in the same manner as their frequencies are more spread out across the data series.

Resting Heart Rate Histograms

Males

Resting Male Heart Rates:

The male resting heart rate follows a normal distribution with the most probable resting heart rate being between 70 BPM and 75 BPM.

Females

Resting Female Heart Rates:

The female resting heart rate somewhat follows a normal distribution. Their most probable resting heart rate is between 75 BPM and 80 BPM.

Normal Probability Plots

Males

The resting Male normal probability plot was generated with the following code. And resulted in next plot.

qqnorm(d$Beats[d$Sex == 1],
main = "Normal Probability for Males",pch = 21,cex = 1,col = "black",bg = "Blue",lwd = 1)
qqline(d$Beats[d$Sex == 1])

The normal probability plot for males shows that the resting heart rates follow the model with a high residual in quantiles -2 to 1. The highest 2-3 resting heart rates have a lower residual.

Females

The resting Female normal probability plot was generated with the following code. And resulted in next plot.

qqnorm(d$Beats[d$Sex == 1],
main = "Normal Probability for Females",pch = 21,cex = 1,col = "black",bg = "Pink",lwd = 1)
qqline(d$Beats[d$Sex == 1])

The normal probability plot for females shows that the resting heart rates also generally follow the model with a high residual, but several of the higher resting heart rates do not follow the model. There is also an outlier with one of the lowest resting heart rates.

Side-by-Side Box Plot

The resting Male and Female heart rates were also plotted using a side-by-side box plot with the following code and outcome.

boxplot(d$Beats[d$Sex == 1],d$Beats[d$Sex == 2],
        main = "Resting Heart Rate Between Male & Female",
        ylab = "Resting Heart Rate (BPM)",
        names = c("Male","Female"),
        col = c("blue","pink"))

The side-by-side box plot shows that the Female median value for resting heart rate is greater than that of Males. It is also clear that the Female distribution is wider than that of Males.

All Source Code

# setup Libraries
library(knitr)
# read in file
d<- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv",
sep=",", na.strings = c("","."))
# clean up first col name and as.factor for sex
names(d)[1] <- "Temp"
d$Sex<- as.factor(d$Sex)
# setup data frame
dataTable<- data.frame(matrix(NA,2,6))
rownames(dataTable)<- c('Male','Female')
colnames(dataTable)<- c('min','max','mean','sd','median','quantile')



# males = 1, females = 2
# men
dataTable$min[1] <- min(d$Beats[d$Sex == 1])
dataTable$max[1] <- max(d$Beats[d$Sex == 1])
dataTable$mean[1] <- mean(d$Beats[d$Sex == 1])
dataTable$sd[1] <- sd(d$Beats[d$Sex == 1])
dataTable$median[1] <- median(d$Beats[d$Sex == 1])
dataTable$quantile[1] <- list(as.vector(quantile(d$Beats[d$Sex == 1])))
# women
dataTable$min[2] <- min(d$Beats[d$Sex == 2])
dataTable$max[2] <- max(d$Beats[d$Sex == 2])
dataTable$mean[2] <- mean(d$Beats[d$Sex == 2])
dataTable$sd[2] <- sd(d$Beats[d$Sex == 2])
dataTable$median[2] <- median(d$Beats[d$Sex == 2])
dataTable$quantile[2] <- list(as.vector(quantile(d$Beats[d$Sex == 2])))



## format Table
# Mean and SD to 2 decimal places
dataTable$mean <- as.numeric(format(round(dataTable$mean,2), nsmall = 2))
dataTable$sd <- as.numeric(format(round(dataTable$sd,2), nsmall = 2))
kable(dataTable,caption = "Statistical Table of Male and Female")