We first bring in our data from an external source and place it in an R dataframe, separating the male and female groups:
dat<-read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv")
male<-dat[dat$Sex==1,]
female<-dat[dat$Sex==2,]
We then do a summary statistical analysis of the male temperature data.
male_temp<-summary(male$Temp)
print(male_temp)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 96.3 97.6 98.1 98.1 98.6 99.5
The sample standard deviation of the male temperature is
male_temp_sd<-sd(male$Temp)
print(male_temp_sd)
## [1] 0.6987558
We do a summary statistical analysis of the female temperature data:
female_temp<-summary(female$Temp)
print(female_temp)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 96.40 98.00 98.40 98.39 98.80 100.80
The female sample standard deviation is
female_temp_sd<-sd(female$Temp)
print(female_temp_sd)
## [1] 0.7434878
The male statistical summary analysis of heart rate is:
male_beats<-summary(male$Beats)
print(male_beats)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 58.00 70.00 73.00 73.37 78.00 86.00
The standard deviation of the male heart rate is
male_beats_sd<-sd(male$Beats)
print(male_beats_sd)
## [1] 5.875184
The female summary statistical analysis for heart rate is:
female_beats<-summary(female$Beats)
print(female_beats)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 57.00 68.00 76.00 74.15 80.00 89.00
The female sample standard deviation of heart rate is:
female_beats_sd<-sd(female$Beats)
print(female_beats_sd)
## [1] 8.105227
The normal probability plot for the male temperature is
# Create the Q-Q plot
qqnorm(male$Temp, xlab = "Male Temp ", main = "Normal Probability Dist. of Male Temp")
qqline(male$Temp, col = "blue", lwd = 2)
The histogram for male temperature is
# Create the histogram
hist(male$Temp,
col = "blue", # Fill color
border = "white", # Optional: makes bars stand out
xlab = "temperature", # X-axis label
main = "Histogram of Male temperature" # Title
)
The normal probability plot for male heart rate is
# Create the Q-Q plot
qqnorm(male$Beats, xlab = "Male Heart Rate", main = "Normal Probability of Male Heart Rate")
qqline(male$Beats, col = "blue", lwd = 2)
The histogram for male heart rate is
hist(male$Beats,
col = "blue", # Fill color
border = "white", # Optional: makes bars stand out
xlab = "Heart Rate", # X-axis label
main = "Histogram of Male Heart Rate" # Title
)
The normal probability plot for the female temperature is
# Create the Q-Q plot
qqnorm(female$Temp, xlab = "female Temp ", main = "Normal Probability Dist. of Female Temp")
qqline(female$Temp, col = "pink", lwd = 2)
The histogram for female temperature is
hist(female$Temp,
col = "pink", # Fill color
border = "white", # Optional: makes bars stand out
xlab = "temperature", # X-axis label
main = "Histogram of female temperature" # Title
)
The normal probability plot for the female heart rate is
# Create the Q-Q plot
qqnorm(female$Beats, xlab = "female Heart Rate", main = "Normal Probability of female Heart Rate")
qqline(female$Beats, col = "pink", lwd = 2)
The histogram for female heart rate is
hist(female$Beats,
col = "pink", # Fill color
border = "white", # Optional: makes bars stand out
xlab = "Heart Rate", # X-axis label
main = "Histogram of female Heart Rate" # Title
)
A side-by-side boxplot comparison of male and female heart rates is shown here:
# Create side-by-side box plots
boxplot(male$Beats, female$Beats,
names = c("Male Heart rate", "Female Heart rate"), # Labels under each box
main = "Comparison of Heart Rates between Male & Female", # Main title
col = c("blue", "lightpink"), # Optional: color for each box
ylab = "Heart Rate") # Label for y-axis
The female heart rate has a greater variance than the male heart rate. This is shown in the larger sample standard deviation of the female sample. The male mean heart rate is also lower than the mean female heart rate. The is also extensive overlap between the male and female heart rate sample data set.
This is the source code for the R script.
dat<-read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv")
male<-dat[dat$Sex==1,]
female<-dat[dat$Sex==2,]
male_temp<-summary(male$Temp)
print(male_temp)
male_temp_sd<-sd(male$Temp)
print(male_temp_sd)
female_temp<-summary(female$Temp)
print(female_temp)
female_temp_sd<-sd(female$Temp)
print(female_temp_sd)
male_beats<-summary(male$Beats)
print(male_beats)
male_beats_sd<-sd(male$Beats)
print(male_beats_sd)
female_beats<-summary(female$Beats)
print(female_beats)
female_beats_sd<-sd(female$Beats)
print(female_beats_sd)
# Create the Q-Q plot
qqnorm(male$Temp, xlab = "Male Temp ", main = "Normal Probability Dist. of Male Temp")
qqline(male$Temp, col = "blue", lwd = 2)
# Create the Q-Q plot
qqnorm(male$Beats, xlab = "Male Heart Rate", main = "Normal Probability of Male Heart Rate")
qqline(male$Beats, col = "blue", lwd = 2)
# Create the Q-Q plot
qqnorm(female$Temp, xlab = "Female Temp ", main = "Normal Probability Dist. of Female Temp")
qqline(female$Temp, col = "pink", lwd = 2)
# Create the Q-Q plot
qqnorm(female$Beats, xlab = "Female Heart Rate", main = "Normal Probability of Female Heart Rate")
qqline(female$Beats, col = "pink", lwd = 2)
# Create the histogram
hist(male$Temp,
col = "blue", # Fill color
border = "white", # Optional: makes bars stand out
xlab = "temperature", # X-axis label
main = "Histogram of Male temperature" # Title
)
hist(male$Beats,
col = "blue", # Fill color
border = "white", # Optional: makes bars stand out
xlab = "Heart Rate", # X-axis label
main = "Histogram of Male Heart Rate" # Title
)
hist(female$Temp,
col = "pink", # Fill color
border = "white", # Optional: makes bars stand out
xlab = "temperature", # X-axis label
main = "Histogram of Female temperature" # Title
)
hist(female$Beats,
col = "pink", # Fill color
border = "white", # Optional: makes bars stand out
xlab = "Heart Rate", # X-axis label
main = "Histogram of Female Heart Rate" # Title
)
# Create side-by-side box plots
boxplot(male$Beats, female$Beats,
names = c("Male Heart rate", "Female Heart rate"), # Labels under each box
main = "Comparison of Heart Rates between Male & Female", # Main title
col = c("blue", "lightpink"), # Optional: color for each box
ylab = "Heart Rate") # Label for y-axis