This document contains the analysis of the resting heart rate of n=65 randomly sampled males and n=65 randomly sampled females. The data is contained in the file normtemp.csv, and all of the data manipulation, analysis and plotting is done within R.
The data is read directly from the web with read.csv().
df<-read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv")
The variable of interest is Beats (resting heart rate), and the variable Sex identifies males (1) and females (2). We now separate the heart rates into two vectors.
male<-df$Beats[df$Sex==1]
female<-df$Beats[df$Sex==2]
cat("summary measures of the resting heart rate of males \n",summary(male),"\n")
## summary measures of the resting heart rate of males
## 58 70 73 73.36923 78 86
The summary above reports, in order, the minimum, the first quartile, the median, the sample mean, the third quartile and the maximum. The sample standard deviation is reported next.
sd(male)
## [1] 5.875184
The resting heart rate of the males ranges from 58 to 86 beats per minute, with a sample mean of about 73.4 and a sample median of 73. The mean and the median are almost identical, which suggests a symmetric distribution. The first and third quartiles are 70 and 78, so the middle 50% of the males fall within a narrow band of only 8 beats per minute, and the sample standard deviation is about 5.9 beats per minute.
hist(male,main="Histogram of the Resting Heart Rate of Males",xlab="Resting Heart Rate of Males (beats per minute)",col="blue")
The histogram is roughly mound shaped and centered near 73 beats per minute. There is no strong skewness and no obvious outlier, which is consistent with the mean and the median being nearly equal.
qqnorm(male,main="Normal Probability Plot of the Resting Heart Rate of Males")
qqline(male)
The points fall close to the straight line with only minor departures in the tails. There is no systematic curvature, so the normal distribution appears to be a reasonable model for the resting heart rate of males.
cat("summary measures of the resting heart rate of females \n",summary(female),"\n")
## summary measures of the resting heart rate of females
## 57 68 76 74.15385 80 89
sd(female)
## [1] 8.105227
The resting heart rate of the females ranges from 57 to 89 beats per minute, with a sample mean of about 74.2 and a sample median of 76. The first and third quartiles are 68 and 80, so the middle 50% of the females spans 12 beats per minute, and the sample standard deviation is about 8.1 beats per minute. The mean is smaller than the median, which indicates a mild left skewness, and the variability is clearly larger than the one observed for the males.
hist(female,main="Histogram of the Resting Heart Rate of Females",xlab="Resting Heart Rate of Females (beats per minute)",col="pink")
The histogram is wider and flatter than the one of the males, and it shows a longer tail towards the lower values. The center is close to 75 beats per minute, but the shape is less clearly mound shaped than the male histogram.
qqnorm(female,main="Normal Probability Plot of the Resting Heart Rate of Females")
qqline(female)
The points follow the straight line reasonably well in the center, with some departure in the lower tail that is consistent with the mild left skewness seen in the histogram. The normality assumption is still acceptable, although the fit is not as good as it is for the males.
boxplot(male,female,main="Resting Heart Rate of Males and Females",names=c("Male","Female"),xlab="Sex",ylab="Resting Heart Rate (beats per minute)",col=c("blue","pink"))
The two box plots have very similar locations. The median of the females is slightly higher than the median of the males, but the difference is small compared with the spread of the data, so the two groups appear to be centered at about the same resting heart rate.
The main difference is in the dispersion. The box of the females is noticeably taller than the box of the males, and the whiskers reach further in both directions, which shows that the resting heart rate of the females is more variable. The male box plot is also more symmetric around its median, while the female box plot is slightly stretched towards the lower values. Neither group shows extreme observations plotted as outliers.
df<-read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv")
male<-df$Beats[df$Sex==1]
female<-df$Beats[df$Sex==2]
cat("summary measures of the resting heart rate of males \n",summary(male),"\n")
sd(male)
hist(male,main="Histogram of the Resting Heart Rate of Males",xlab="Resting Heart Rate of Males (beats per minute)",col="blue")
qqnorm(male,main="Normal Probability Plot of the Resting Heart Rate of Males")
qqline(male)
cat("summary measures of the resting heart rate of females \n",summary(female),"\n")
sd(female)
hist(female,main="Histogram of the Resting Heart Rate of Females",xlab="Resting Heart Rate of Females (beats per minute)",col="pink")
qqnorm(female,main="Normal Probability Plot of the Resting Heart Rate of Females")
qqline(female)
boxplot(male,female,main="Resting Heart Rate of Males and Females",names=c("Male","Female"),xlab="Sex",ylab="Resting Heart Rate (beats per minute)",col=c("blue","pink"))