#Load Data
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
dat$Sex <- as.factor(dat$Sex)
str(dat)
## 'data.frame': 130 obs. of 3 variables:
## $ Temp : num 96.3 96.7 96.9 97 97.1 97.1 97.1 97.2 97.3 97.4 ...
## $ Sex : Factor w/ 2 levels "1","2": 1 1 1 1 1 1 1 1 1 1 ...
## $ Beats: int 70 71 74 80 73 75 82 64 69 70 ...
#Statistical Analysis of Males Data
Males <- dat[dat$Sex==1,]
summary(Males$Beats)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 58.00 70.00 73.00 73.37 78.00 86.00
sd(Males$Beats)
## [1] 5.875184
Comment:From the statistical analysis, the minimum value is 58, maximum value is 86, mean and median are 73 and 73.37 respectively. The standard deviation is 5.875.
#Histogram and Normal Probability Plot of Males Data
hist(Males$Beats, main ='Males Hearbets in Histogram plot', col= 'blue', xlab ='Heartbeats', ylab ='Frequency')
qqnorm(Males$Beats, main ='Males Hearbets in Normal Probability plot', col ='blue')
Comment: From the histogram plot, the data is primarily centered within the range from 70 to 75. And for the Normal Probability plot, the sample and theoretical quantiles are from the range of -1 to +1.the points mostly follow the straight line.
#Statistical Analysis of Females Data
Females <- dat[dat$Sex==2,]
summary(Females$Beats)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 57.00 68.00 76.00 74.15 80.00 89.00
sd(Females$Beats)
## [1] 8.105227
Comment:From the statistical analysis, the minimum value is 57, maximum value is 89, mean and median are 74.15 and 76 respectively. The standard deviation is 8.105.
#Histogram and Normal Probability Plot of Females Data
hist(Females$Beats, main ='Females Hearbets in Histogram plot', col= 'pink', xlab ='Heartbeats', ylab ='Frequency')
qqnorm(Females$Beats, main ='Females Hearbets in Normal Probability plot', col ='pink')
Comment: From the histogram plot, the data is primarily centered within the range from 75 to 80. And for the Normal Probability plot, the sample and theoretical quantiles are from the range of -1 to +1.the points mostly follow the straight line.
#Boxplot for Heartbeats of Males and Females
boxplot(Males$Beats, Females$Beats, ylab= 'Heartbeat', names = c("Male", "Female"))
Comment for similarities or differences between the box plots of heartbeats of males and females:
The median heart rate for males appears slightly lower than that for females. The interquartile range for females is greater than for the males. There are no visible outliers for both males and females. The mean is higher for females than the males. The maximum range is slightly higher for females(i.e.89) than the males(i.e.86).
#Complete Code:
dat <- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv")
head(dat)
dat$Sex <- as.factor(dat$Sex)
str(dat)
Males <- dat[dat$Sex==1,]
summary(males$Beats)
sd(Males$Beats)
hist(Males$Beats, main ='Males Hearbets in Histogram plot', col= 'blue', xlab ='Heartbeats', ylab ='Frequency')
qqnorm(Males$Beats, main ='Males Hearbets in Normal Probability plot', col ='blue')
Females <- dat[dat$Sex==2,]
summary(Females$Beats)
sd(Females$Beats)
hist(Females$Beats, main ='Females Hearbets in Histogram plot', col= 'pink', xlab ='Heartbeats', ylab ='Frequency')
qqnorm(Females$Beats, main ='Females Hearbets in Normal Probability plot', col ='pink')
boxplot(Males$Beats, Females$Beats, ylab= 'Heartbeat', names = c("Male", "Female"))