Purpose

The purpose of this analysis is to to compare the resting heartbeats of males and females.

Basic Filtering

At first the raw data was separated into 2 dataframes with datf listing a range of female heartbeats and datm for male heartbeats.

dat <- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv")
# 1 is male 2 is female
 datm <- dat[dat$Sex == 1,]
 
 datf <- dat[dat$Sex == 2,]
# the lines above create 2 dataframes filtering the data so that males and females are separated with males in 
 # datm and females in datf

Here is the dataframe with the male heartbeats.

 head(datm)
##   ï..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

Here is the dataframe with the female heartbeats.

 head(datf)
##    ï..Temp Sex Beats
## 66    96.4   2    69
## 67    96.7   2    62
## 68    96.8   2    75
## 69    97.2   2    66
## 70    97.2   2    68
## 71    97.4   2    57

Male Summary statistics

Below is a five number summary of the data for male heartbeats

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   58.00   70.00   73.00   73.37   78.00   86.00

The following is the standard deviation

sd(datm$Beats)
## [1] 5.875184

Below a histogram and normal probability plot is included.

hist(datm$Beats,
     main="Histogram of Male Heartbeats",
     xlab = "Beats",
     col= "blue")

qqnorm(datm$Beats,
       main = "Normal Probablillity Plot for Males",
       ylab= "Heartbeats")

It can be seen that male heartbeats follow a normal distribution with virtually no skew. The normal probability plot seems pretty linear which further confirms the normal distribution

Female Summary Statistics

Below is a five number summary of the data for female heartbeats.

summary(datf$Beats)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   57.00   68.00   76.00   74.15   80.00   89.00

Listed here is the standard deviation for female heartbeats

sd(datf$Beats)
## [1] 8.105227

Below a histogram and normal probability plot is included.

hist(datf$Beats,
     main="Histogram of Female Heartbeats",
     xlab = "Beats",
     col= "pink")

Here it can be seen that the distribution of female heartbeats is skewed to the left.

qqnorm(datf$Beats,
       main = "Normal Probablillity Plot for Females",
       ylab= "Heartbeats")

It can be seen that female heartbeats skew to the left. The slope of the normal probability plot seems to be linear but has a lower y-intercept than the males.

BoxPlots!

Here is a side by side boxplot of male vs female heartbeats

# the following lists the side by side boxplot

boxplot( datm$Beats, datf$Beats,
         names = c("Male Heartbeats", "Female HeartBeats"),
         ylab= "Frequency",
         col= c("blue","pink"),
         main = "Boxplots of Male vs. Female Heartbeats")

As visually demonstrated by the box plot female heartbeats in general beat at a faster pace than males. With a higher mean and higher 3rd quartile.

Female beats have a wider distribution with the minimum heartbeat being lower than the lowest male and the highest female heartbeat is higher than the highest male.

Analysis

As seen by the box plots and histograms, in general female hearts beat at a faster pace than males and there is more variation in the female beats as seen by the larger standard deviation.

When comparing the histograms, female heartbeats slightly skew to the left, while the male are more normally distributed. This is again confirmed by the normal probability plots

It is interesting to see that the male heartbeat is more normally distributed when compared with the females, with the spread of the data being tighter than the female heartbeats as given by smaller standard deviation.

Complete R Code

dat <- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv")
# 1 is male 2 is female
 datm <- dat[dat$Sex == 1,]
 
 datf <- dat[dat$Sex == 2,]
# the lines above create 2 dataframes filtering the data so that males and females are seperated with males in 
 # datm and females in datf
 
 # the following lines list the summary stats for males
summary(datm$Beats)
sd(datm$Beats)
hist(datm$Beats,
     main="Histogram of Male Heartbeats",
     xlab = "Beats",
     col= "blue")
qqnorm(datm$Beats,
       main = "Normal Probablillity Plot for Males",
       ylab= "Heartbeats")

# The following lines list the summary stats for females

summary(datf$Beats)
sd(datf$Beats)
hist(datf$Beats,
     main="Histogram of Female Heartbeats",
     xlab = "Beats",
     col= "pink")
qqnorm(datf$Beats,
       main = "Normal Probablillity Plot for Females",
       ylab= "Heartbeats")

# the following lists the side by side boxplot

boxplot( datm$Beats, datf$Beats,
         names = c("Male Heartbeats", "Female HeartBeats"),
         ylab= "Frequency",
         col= c("blue","pink"),
         main = "Boxplots of Male vs. Female Heartbeats")