Using the Excel file Facebook Survey, determine if the mean number of hours spent online per week is the same for males as it is for females.
The following is the data FaceBook
imported from Excel:
library(readxl)
FB <- read_excel("F:/Data_Files/Facebook Survey.xlsx",range = "A3:D36")
head(FB)
First, we test for variances:
var.test(FB$`Hours online/week` ~ FB$Gender)
F test to compare two variances
data: FB$`Hours online/week` by FB$Gender
F = 0.97782, num df = 19, denom df = 12, p-value =
0.9347
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
0.3164907 2.6592598
sample estimates:
ratio of variances
0.9778224
Now, based on the variance test results, we test for means
t.test(FB$`Hours online/week` ~ FB$Gender,var.equal=T)
Two Sample t-test
data: FB$`Hours online/week` by FB$Gender
t = -0.20704, df = 31, p-value = 0.8373
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-2.545736 2.076506
sample estimates:
mean in group female mean in group male
6.150000 6.384615