knitr::opts_chunk$set(echo = TRUE)
This assignment involved analyzing the resting heart rate from the following data for males (1) and for females (2).
data <- data.frame(read.csv("C:/Users/cephusm/Downloads/normtemp.csv"))
rmarkdown::paged_table(data)
The male and female stastical analysis can be found below.
#males
m <- data.frame(data[1:65,])
#male resting heart rate
mhr <- m$Beats
mhr <- as.numeric(mhr)
mmin <- min(mhr)
mmax <- max(mhr)
mmean <- mean(mhr)
msd <- sd(mhr)
mmedian <- median(mhr)
mquartiles <- quantile(mhr)
mdata <- c(mmin,mmax,mmean,msd,mmedian)
#females
f <- data.frame(data[66:130,])
fhr <- f$Beats
fhr <- as.numeric(fhr)
fmin <- min(fhr)
fmax <- max(fhr)
fmean <- mean(fhr)
fsd <- sd(fhr)
fmedian <- median(fhr)
fquartiles <- quantile(fhr)
fdata <- c(fmin,fmax,fmean,fsd,fmedian)
adata <- data.frame(mdata,fdata)
colnames(adata) <- c("Male","Female")
rownames(adata) <- c("Min","Max","Mean","Standard Deviation","Median")
rmarkdown::paged_table(adata)
Looking at the data above we can conclude that females have a wider range of heart rates than males since they have the lowest min, highest max, and bigger standard deviation. Females also had a higher mean and median so we can conclude that on average females have a higher heart rate.
Below are the histograms of the male and female data of their heart rates. From these grafts we can see that for males the results are almost normalized with a peak in the middle between 70 and 75. For females the data skew slightly to te right with the mode being between 75 and 80. This graph agrees with the conclusions drawn from the analyzed statistics.
hist(mhr, main="Male Heart Rate", xlab="Beats Per Minute", col="blue")
hist(fhr, main="Female Heart Rate", xlab="Beats Per Minute", col="pink")
Next are the normal probability plots for the male and female heart rates. The female line best fit line is noticeably steeper than the male line implying females, again, have higher heart rates.
qqnorm(mhr, main="Male Heart Rate", ylab="Beats Per Minute")
qqline(mhr, col="blue")
qqnorm(fhr, main="Female Heart Rate", ylab="Beats Per Minute")
qqline(fhr, col="pink")
Lastly, here are the quartile ranges for the male and female heart rate data as well as their respective box and whisker plots. The box and whisker plots show the higher median of the female heart rates and the bigger range of outliers.
boxdata <- data.frame(mquartiles,fquartiles)
colnames(boxdata) <- c("Male Quartiles","Female Quartiles")
rmarkdown::paged_table(boxdata)
boxplot(mhr, main="Male Heart Rate", ylab="Beats Per Minute", col="blue")
boxplot(fhr, main="Female Heart Rate", ylab="Beats Per Minute", col="pink")
The entire code that I used to analyse the data and make the above plots can be found below.
#Meghan Cephus
#09/01/2024
#Flipped Assignment 2
setwd("C:/Users/cephusm/Documents/TTU")
data <- data.frame(read.csv("C:/Users/cephusm/Downloads/normtemp.csv"))
#males
m <- data.frame(data[1:65,])
#male resting heart rate
mhr <- m$Beats
mhr <- as.numeric(mhr)
mmin <- min(mhr)
mmax <- max(mhr)
mmean <- mean(mhr)
msd <- sd(mhr)
mmedian <- median(mhr)
mquartiles <- quantile(mhr)
mdata <- c(mmin,mmax,mmean,msd,mmedian)
hist(mhr, main="Male Heart Rate", xlab="Beats Per Minute", col="blue")
qqnorm(mhr, main="Male Heart Rate", ylab="Beats Per Minute")
qqline(mhr, col="blue")
boxplot(mhr, main="Male Heart Rate", ylab="Beats Per Minute", col="blue")
#females
f <- data.frame(data[66:130,])
fhr <- f$Beats
fhr <- as.numeric(fhr)
fmin <- min(fhr)
fmax <- max(fhr)
fmean <- mean(fhr)
fsd <- sd(fhr)
fmedian <- median(fhr)
fquartiles <- quantile(fhr)
fdata <- c(fmin,fmax,fmean,fsd,fmedian)
adata <- data.frame(mdata,fdata)
colnames(adata) <- c("Male","Female")
rownames(adata) <- c("Min","Max","Mean","Standard Deviation","Median")
hist(fhr, main="Female Heart Rate", xlab="Beats Per Minute", col="pink")
qqnorm(fhr, main="Female Heart Rate", ylab="Beats Per Minute")
qqline(fhr, col="pink")
boxplot(fhr, main="Female Heart Rate", ylab="Beats Per Minute", col="pink")
boxdata <- data.frame(mquartiles,fquartiles)
colnames(boxdata) <- c("Male Quartiles","Female Quartiles")