Data Wrangling

Below is the script we used to bring in the data:

# Resting Body Temperature and Resting Heart Rate
dat<-read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv")
head(dat)
##   ï..Temp Sex Beats
## 1    96.3   1    70
## 2    96.7   1    71
## 3    96.9   1    74
## 4    97.0   1    80
## 5    97.1   1    73
## 6    97.1   1    75

Now that we have the data, we begin to clean it up to prep for analysis.

Temp <- c(dat$ï..Temp) 
Sex <- c(dat$Sex)
Beats <- c(dat$Beats)

Mens’ Output

Extracting the male and female data

males<-dat[1:65,]
females<-dat[66:130,]

#Men data:
head(males$Beats)
## [1] 70 71 74 80 73 75
#Women data:
head(females$Beats)
## [1] 69 62 75 66 68 57

Shown below is summary of the Males’ Resting Heart Rate

summary(males$Beats)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   58.00   70.00   73.00   73.37   78.00   86.00
sd(males$Beats)
## [1] 5.875184
IQR(males$Beats)
## [1] 8
hist(males$Beats, xlab="Beats Per Min",
     main="Males Resting Heart Rate",col="blue")

msd <- sd(males$Beats)
mmean <- mean(males$Beats)
mmin <- min(males$Beats)
mmax <- max(males$Beats)

curve(dnorm(x,mmean,msd),mmin,mmax,xlab="Beats Per Min",
      ylab="Density",main="Male", col="blue")

Womens’ Output

summary(females$Beats)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   57.00   68.00   76.00   74.15   80.00   89.00
sd(females$Beats)
## [1] 8.105227
IQR(females$Beats)
## [1] 12
hist(females$Beats, xlab="Beats Per Min",
     main="Females Resting Heart Rate",col="magenta")

fsd <- sd(females$Beats)
fmean <- mean(females$Beats)
fmin <- min(females$Beats)
fmax <- max(females$Beats)

curve(dnorm(x,fmean,fsd),fmin,fmax,xlab="Beats Per Min",
      ylab="Density",main="Female", col="magenta")

Males vs Females Plot

Below are our plots

boxplot(males$Beats,main="Male Rate",ylab="Beats Per Min",col="blue")
boxplot(females$Beats,main="Female Rate", ylab="Beats Per Min",col="magenta")

Analysis of the Data and Plots

Male

The Mens’ resting heart rate nearly follows a normal distribution, the Mean and the Median are very close to each other. The distance from the mean to each quartile is similar.

Female

The Womens’ resting heart rate does not closely follow a normal distribution, the mean and are almost 2 beats apart and the distance from the Median to the quartiles are 8 and 14 beats per minute.

Males vs Females

The males’ resting heart rate, as in the previous graphs, presents a more normalized distribution than the slightly skewed box plot for female resting heart rate. The male IQR is slightly smaller than the female, with a median closer to the middle of the 1st and 3rd quartiles, whereas the female median is closer to the 1st quartile. Additionally, the range of the sampled male heart rates is shown to be smaller than the same for female, creating more precise data.

All Code

Below is the r code used in this script:

# Resting Body Temperature and Resting Heart Rate
dat<-read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv")
head(dat)

Temp <- c(dat$ï..Temp) 
Sex <- c(dat$Sex)
Beats <- c(dat$Beats)

males<-dat[1:65,]
females<-dat[66:130,]

#Men data:
head(males$Beats)
#Women data:
head(females$Beats)

summary(males$Beats)
sd(males$Beats)
IQR(males$Beats)

hist(males$Beats, xlab="Beats Per Min",
     main="Males Resting Heart Rate",col="blue")

msd <- sd(males$Beats)
mmean <- mean(males$Beats)
mmin <- min(males$Beats)
mmax <- max(males$Beats)

curve(dnorm(x,mmean,msd),mmin,mmax,xlab="Beats Per Min",
      ylab="Density",main="Male", col="blue")

summary(females$Beats)
sd(females$Beats)
IQR(females$Beats)

hist(females$Beats, xlab="Beats Per Min",
     main="Females Resting Heart Rate",col="magenta")

fsd <- sd(females$Beats)
fmean <- mean(females$Beats)
fmin <- min(females$Beats)
fmax <- max(females$Beats)

curve(dnorm(x,fmean,fsd),fmin,fmax,xlab="Beats Per Min",
      ylab="Density",main="Female", col="magenta")

boxplot(males$Beats,main="Male Rate",ylab="Beats Per Min",col="blue")
boxplot(females$Beats,main="Female Rate", ylab="Beats Per Min",col="magenta")