1 Problem #1:

For this assignment, you will be submitting a webpage with the requested analysis of the data.  The html link (only) should be submitted through blackboard.  The webpage should be created with RMarkdown and analysis self-contained (i.e. all data manipulation, analysis, plotting, etc. should be done within R).  The code that was used should be included and displayed results throughout your webpage (echo=TRUE) and the complete code should also be included at the end of your webpage (eval=FALSE).   

Specifically, consider the file normtemp.csv that contains measurements on the resting body temperature and resting heart rate of n=65 randomly sampled males (1) and n=65 randomly sampled females (2).  This file may be downloaded directly into R using read.csv() with the following link.  

https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv

We would like to analyze only the resting heart rate in this analysis

  • For males, perform an analysis that includes the descriptive statistics (e.g. min, max, sample mean, sample standard deviation, sample median, quartiles), histogram, and normal probability plot.  Comment on the statistics and plots.  Repeat the same for females.  Be sure to uniquely label the title and x-axis, and color the histograms (male-blue, female-pink).  

  • Create side by side box plots that compare the resting heart rate of males and females.  Be sure to title and label (male/female) the box plots. Comment on what you see in the box plots (similarities and/or differences)

1.1 Analysis:

##This assigns the dataset to 'datset1'
datset1<-read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv")

MaleHR<-datset1[1:65,3]  #This assigns Male-Heart Rate
FemaleHR<-datset1[66:130,3]  #This assigns Female-Heart Rate

1.1.1 Descriptive Statistics for Male

mean(MaleHR)
## [1] 73.36923
max(MaleHR)
## [1] 86
var(MaleHR)
## [1] 34.51779
sd(MaleHR)
## [1] 5.875184
IQR(MaleHR)
## [1] 8
summary(MaleHR)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   58.00   70.00   73.00   73.37   78.00   86.00
hist(MaleHR, main = "Histogram of Male Heart Beats",col = "blue")

qqnorm((MaleHR),main="Normal QQ Plot of Male Heart Beats") 

1.1.2 Descriptive Statistics for Female

mean(FemaleHR)
## [1] 74.15385
max(FemaleHR)
## [1] 89
var(FemaleHR)
## [1] 65.69471
sd(FemaleHR)
## [1] 8.105227
IQR(FemaleHR)
## [1] 12
summary(FemaleHR)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   57.00   68.00   76.00   74.15   80.00   89.00
hist(FemaleHR, main = "Histogram of Male Heart Beats",col = "pink")

qqnorm((FemaleHR),main="Normal QQ Plot of Female Heart Beats")

1.2 Side by Side Box Plots of Male & Female

boxplot(MaleHR,FemaleHR,names = c("Males","Females"),main="boxplot of Males and Females",ylab="Heartrates")

1.3 Overall Analysis

Mean: the female population has a mean of 74.15, while the make population has a mean of 73.37, giving a percentage difference of 1.06% putting the female poulation at a higher value

Standard Deviation: The male population has a SD of 5.88, while the female population has a SD of 8.105. This makes the SD of the female population 37.75% higher

Median: the male population has a median of 76, and the female population has a median of 73

Normal Probability Curve: For the male, we have an histogram with a taller bar at the middle, giving a bell curve that fits perfectly. This can be traced to the lower value of the SD of the male

The female, on the other hand has an histogram that is flat towards the left. This can be traced to the higher value of the SD which makes the data skewed

Conclusion

Judging by the statistical data for female, they have a higher value compared to the male population. As a result, the female have a more diversed data compared to the male

1.4 Complete R Code

##This assigns the dataset to 'datset1'
datset1<-read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv")

MaleHR<-datset1[1:65,3]  #This assigns Male-Heart Rate
FemaleHR<-datset1[66:130,3]  #This assigns Female-Heart Rate

#Male Descriptive Stats#
mean(MaleHR)
max(MaleHR)
var(MaleHR)
sd(MaleHR)
IQR(MaleHR)
summary(MaleHR)
hist(MaleHR, main = "Histogram of Male Heart Beats",col = "blue")
qqnorm((MaleHR),main="Normal QQ Plot of Male Heart Beats") 

#Female Descriptive Stats#
mean(FemaleHR)
max(FemaleHR)
var(FemaleHR)
sd(FemaleHR)
IQR(FemaleHR)
summary(FemaleHR)
hist(FemaleHR, main = "Histogram of Male Heart Beats",col = "pink")
qqnorm((FemaleHR),main="Normal QQ Plot of Female Heart Beats")

#Computing Plots#
boxplot(MaleHR,FemaleHR,names = c("Males","Females"),main="boxplot of Males and Females",ylab="Heartrates")