library(readxl)
## Warning: package 'readxl' was built under R version 4.1.3
bmi <- read_excel("C:/Users/Lab pc/Downloads/bmi.xlsx")
View(bmi)
attach(bmi)
names(bmi)
## [1] "BMI" "Height" "Weight" "Gender"
#Ho : mu<8 + 95% confidence interval
t.test(BMI, mu = 20,alternative="two.side",conf.level =0.95)
##
## One Sample t-test
##
## data: BMI
## t = 0.80547, df = 9, p-value = 0.4413
## alternative hypothesis: true mean is not equal to 20
## 95 percent confidence interval:
## 18.71598 22.70402
## sample estimates:
## mean of x
## 20.71
boxplot(BMI ~ Gender)

#Ho : BMI OF MALE = BMI OF FEMALE
#assumption - non-equal variances
t.test(BMI ~ Gender, mu=0, alt="two.sided", paired=F, conf.level=0.95)
##
## Welch Two Sample t-test
##
## data: BMI by Gender
## t = -2.143, df = 7.5951, p-value = 0.06629
## alternative hypothesis: true difference in means between group Female and group Male is not equal to 0
## 95 percent confidence interval:
## -6.2063093 0.2563093
## sample estimates:
## mean in group Female mean in group Male
## 18.925 21.900
#By default values which t.test takes are mention in the above line
t.test(BMI ~ Gender)
##
## Welch Two Sample t-test
##
## data: BMI by Gender
## t = -2.143, df = 7.5951, p-value = 0.06629
## alternative hypothesis: true difference in means between group Female and group Male is not equal to 0
## 95 percent confidence interval:
## -6.2063093 0.2563093
## sample estimates:
## mean in group Female mean in group Male
## 18.925 21.900
t.test(BMI[Gender=='Male'],BMI[Gender=='Female'])
##
## Welch Two Sample t-test
##
## data: BMI[Gender == "Male"] and BMI[Gender == "Female"]
## t = 2.143, df = 7.5951, p-value = 0.06629
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.2563093 6.2063093
## sample estimates:
## mean of x mean of y
## 21.900 18.925