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
First, we will separate the raw data based on the sex and analyze for male and female separately.
M <- dat[dat$Sex == 1, ]
F <- dat[dat$Sex == 2, ]
We will only use the resting heart rate for this analysis.
male.stats <- c(Minimum = min(M$Beats), Q1 = quantile(M$Beats, 0.25), Median = median(M$Beats), Mean = mean(M$Beats), Q3 = quantile(M$Beats, 0.75), Maximum = max(M$Beats), SD = sd(M$Beats))
male.stats
## Minimum Q1.25% Median Mean Q3.75% Maximum SD
## 58.000000 70.000000 73.000000 73.369231 78.000000 86.000000 5.875184
From the statistics of the males, we can observe the overall scenerio. The resting heart rate for males ranges from 58 to 86 beats per minute. The mean and the median are quite close with 73.37 and 73 beats per minute. The first and third quartile is 70 and 78 which denotes that the middle 50% of the resting heart rates lies between the range of 70 to 78 beats per minute. Finally, the standard deviation was 5.87 beats per minute.
hist(M$Beats, col = "blue", main = "Histogram of Male Resting Heart Rate", xlab = "Male Resting Heart Rate (beats per minute)", ylab = "Frequency")
This figure is the histogram for the male resting heart rates. The highest frequency was observed for the 70 to 75 range where we got the “Mean” and the “Median”.
qqnorm(M$Beats, main = "Normal Probability Plot of Male Resting Heart Rate", xlab = "Theoretical Quantiles", ylab = "Male Resting Heart Rate")
qqline(M$Beats)
From this figure, we can observe that most of the points are close to the reference line and this indicates a good normally distributed plot.
Similarly, we will do the same analysis for the females.
female.stats <- c( Minimum = min(F$Beats), Q1 = quantile(F$Beats, 0.25), Median = median(F$Beats), Mean = mean(F$Beats), Q3 = quantile(F$Beats, 0.75), Maximum = max(F$Beats), SD = sd(F$Beats))
female.stats
## Minimum Q1.25% Median Mean Q3.75% Maximum SD
## 57.000000 68.000000 76.000000 74.153846 80.000000 89.000000 8.105227
The resting heart rate for females ranges from 57 to 89 beats per minute. The mean is approximately 74.15, while the median is 76. The sample standard deviation is around 8.11 beats per minute.
hist(F$Beats, col = "pink", main = "Histogram of Female Resting Heart Rate", xlab = "Female Resting Heart Rate (beats per minute)", ylab = "Frequency")
The female heart rates are concentrated between 65 and 85 beats per minute. The distribution appears reasonably symmetric, although there is some variation.
qqnorm(F$Beats, main = "Normal Probability Plot of Female Resting Heart Rate", xlab = "Theoretical Quantiles", ylab = "Female Resting Heart Rate")
qqline(F$Beats)
From this figure we can observe that, most of the points are close to the reference line. The overall distribution appears approximately normal.
boxplot(M$Beats, F$Beats, names = c("Male", "Female"), col = c("blue", "pink"), main = "Comparison of Male and Female Resting Heart Rates", ylab = "Resting Heart Rate (beats per minute)", xlab = "Sex")
The box plot shows that there is distinctive differences between the males and the females. The female median is 76, compared with 73 beats per minute for males. The middle 50% of female heart rates range from 68 to 80 beats per minute, whereas the middle 50% of male heart range from 70 to 78 beats per minute. Therefore, the box is wider for the females than the males. finally, neither groups demonstrated any obvious outliers in the box plots.
dat <- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv")
head(dat)
M <- dat[dat$Sex == 1, ]
F <- dat[dat$Sex == 2, ]
male.stats <- c(Minimum = min(M$Beats), Q1 = quantile(M$Beats, 0.25), Median = median(M$Beats), Mean = mean(M$Beats), Q3 = quantile(M$Beats, 0.75), Maximum = max(M$Beats), SD = sd(M$Beats))
male.stats
hist(M$Beats, col = "blue", main = "Histogram of Male Resting Heart Rate", xlab = "Male Resting Heart Rate (beats per minute)", ylab = "Frequency")
qqnorm(M$Beats, main = "Normal Probability Plot of Male Resting Heart Rate", xlab = "Theoretical Quantiles", ylab = "Male Resting Heart Rate")
qqline(M$Beats)
female.stats <- c( Minimum = min(F$Beats), Q1 = quantile(F$Beats, 0.25), Median = median(F$Beats), Mean = mean(F$Beats), Q3 = quantile(F$Beats, 0.75), Maximum = max(F$Beats), SD = sd(F$Beats))
female.stats
hist(F$Beats, col = "pink", main = "Histogram of Female Resting Heart Rate", xlab = "Female Resting Heart Rate (beats per minute)", ylab = "Frequency")
qqnorm(F$Beats, main = "Normal Probability Plot of Female Resting Heart Rate", xlab = "Theoretical Quantiles", ylab = "Female Resting Heart Rate")
qqline(F$Beats)
boxplot(M$Beats, F$Beats, names = c("Male", "Female"), col = c("blue", "pink"), main = "Comparison of Male and Female Resting Heart Rates", ylab = "Resting Heart Rate (beats per minute)", xlab = "Sex")