read csv file
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
get male data:
maleData <- dat[dat$Sex==1,]
head(maleData)
## 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
show statistical data for male:
summary(maleData$Beats)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 58.00 70.00 73.00 73.37 78.00 86.00
stdMale <- sd(maleData$Beats)
print(stdMale)
## [1] 5.875184
Comment: From the above statistical data, for male heart rate data, the minimum is 58, the median is 73, the maximum is 86, the mean is 73.37 and the standard deviation is 5.87518. The 1st quartile value is 70 and the 3rd quartile value is 78 for male resting heart rate data.
show histogram and normal distribution plot:
hist(maleData$Beats, main="Histogram of Male Data", xlab="Male Data", col="blue")
qqnorm(maleData$Beats, main="Normal Porbability plot of Male Data", col="blue")
qqline(maleData$Beats)
comments: From the above figures, we can see that the histogram normal distribution for the male resting heart rate is between 70 and 75. From the normal probability plot, we can see that the Theoetical quantiles and the sample quantiles have linear relationship. The maximum values are between -1 and 1.
get female data:
femaleData <- dat[dat$Sex==2,]
head(femaleData)
## Temp Sex Beats
## 66 96.4 2 69
## 67 96.7 2 62
## 68 96.8 2 75
## 69 97.2 2 66
## 70 97.2 2 68
## 71 97.4 2 57
show statistical data for female:
summary(femaleData$Beats)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 57.00 68.00 76.00 74.15 80.00 89.00
stdFemale <- sd(femaleData$Beats)
print(stdFemale)
## [1] 8.105227
comments: From the above statistical data, the female data has the minimum value of 57, median value is 76, the max value is 89, the 1st quartile is 68 and the 3rd quartile is 80. The standard deviation value for female resting heart rate is 8.105227.
show histogram and normal distribution plot for female:
hist(femaleData$Beats, main="Histogram of Female Data", xlab="female Data", col="pink")
qqnorm(femaleData$Beats, main="Normal Porbability plot of Female Data", col="pink")
qqline(femaleData$Beats)
comments: From the above figures, we can see that the histogram normal distribution for the female resting heart rate is between 75 and 80. From the normal probability plot, we can see that the Theoetical quantiles and the sample quantiles have linear relationship. The maximum values are between -1 and 1 for female heart resting heart rate.
boxplot for both male and female:
boxplot(maleData$Beats, femaleData$Beats, names = c("Male", "Female"), col = c("blue","pink"))
Comments: The box plot of for female resting heart rate, it has the higher median value compare to male data. The range of values is also higher for female data. The variability for female heart rate data is higher between the 1st and 3rd quartile range. For male and female the maximum range is about 86 and 89, while the minimum range is almost similiar at 58 and 57 respectively.
Complete code:
dat <- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv")
head(dat)
maleData <- dat[dat$Sex==1,]
head(maleData)
summary(maleData$Beats)
stdMale <- sd(maleData$Beats)
print(stdMale)
hist(maleData$Beats, main="Histogram of Male Data", xlab="Male Data", col="blue")
qqnorm(maleData$Beats, main="Normal Porbability plot of Male Data", col="blue")
qqline(maleData$Beats)
femaleData <- dat[dat$Sex==2,]
head(femaleData)
summary(femaleData$Beats)
stdFemale <- sd(femaleData$Beats)
print(stdFemale)
hist(femaleData$Beats, main="Histogram of Female Data", xlab="female Data", col="pink")
qqnorm(femaleData$Beats, main="Normal Porbability plot of Female Data", col="pink")
qqline(femaleData$Beats)
boxplot(maleData$Beats, femaleData$Beats, names = c("Male", "Female"), col = c("blue","pink"))