library(dplyr)
## 
## 다음의 패키지를 부착합니다: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
setwd("c:/data")
df<-read.csv("df.csv")
table(df$Sex)
## 
##  1  2 
## 88 26
attach(df)
var.test(harm~Sex)
## 
##  F test to compare two variances
## 
## data:  harm by Sex
## F = 1.3769, num df = 87, denom df = 25, p-value = 0.3669
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
##  0.6855943 2.4679015
## sample estimates:
## ratio of variances 
##           1.376914
t.test(harm~Sex,var.equal=TRUE)
## 
##  Two Sample t-test
## 
## data:  harm by Sex
## t = 0.9792, df = 112, p-value = 0.3296
## alternative hypothesis: true difference in means between group 1 and group 2 is not equal to 0
## 95 percent confidence interval:
##  -0.2379747  0.7030096
## sample estimates:
## mean in group 1 mean in group 2 
##        1.886364        1.653846
table(df$Edu)
## 
##  1  2  3  4 99 
##  1 45 64  3  1
df1<-df %>% filter(Edu!=99)
df1$Edu<-as.factor(df1$Edu)
df1$Edu1[df1$Edu==1]<-2
df1$Edu1[df1$Edu==2]<-2
df1$Edu1[df1$Edu==3]<-4
df1$Edu1[df1$Edu==4]<-4
attach(df1)
## The following objects are masked from df:
## 
##     Age, Career, clean, clean_no, clean_use, comply_1, comply_2,
##     comply_3, comply_4, comply_5, composition, disease, Edu,
##     edu_charge, edu_imp, edu_need, edu_time, harm, headcount, num,
##     part_1, part_2, part_3, part_4, place, recruit, rule_1, rule_2,
##     rule_3, rule_4, rule_5, rule_effect, sales, Sex, skill, smoke,
##     system_need, tail_29_1, tail_29_2, tail_29_3, tail_29_4, tail_29_5,
##     tail_31_1, tail_31_2, tail_31_3, tail_31_4, tail_31_5, Task, test,
##     year_no_1, year_no_2
var.test(harm~Edu1)                
## 
##  F test to compare two variances
## 
## data:  harm by Edu1
## F = 0.70502, num df = 45, denom df = 66, p-value = 0.2155
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
##  0.4159171 1.2290489
## sample estimates:
## ratio of variances 
##           0.705016
t.test(harm~Edu1) 
## 
##  Welch Two Sample t-test
## 
## data:  harm by Edu1
## t = -0.30925, df = 106.47, p-value = 0.7577
## alternative hypothesis: true difference in means between group 2 and group 4 is not equal to 0
## 95 percent confidence interval:
##  -0.4544544  0.3318068
## sample estimates:
## mean in group 2 mean in group 4 
##        1.804348        1.865672
df$Career1[df$Career==2]<-1
df$Career1[df$Career==3]<-5
df$Career1[df$Career==3]<-4
table(df$Career1)
## 
##  1  4 
## 45 25
attach(df)
## The following objects are masked from df1:
## 
##     Age, Career, clean, clean_no, clean_use, comply_1, comply_2,
##     comply_3, comply_4, comply_5, composition, disease, Edu,
##     edu_charge, edu_imp, edu_need, edu_time, harm, headcount, num,
##     part_1, part_2, part_3, part_4, place, recruit, rule_1, rule_2,
##     rule_3, rule_4, rule_5, rule_effect, sales, Sex, skill, smoke,
##     system_need, tail_29_1, tail_29_2, tail_29_3, tail_29_4, tail_29_5,
##     tail_31_1, tail_31_2, tail_31_3, tail_31_4, tail_31_5, Task, test,
##     year_no_1, year_no_2
## The following objects are masked from df (pos = 4):
## 
##     Age, Career, clean, clean_no, clean_use, comply_1, comply_2,
##     comply_3, comply_4, comply_5, composition, disease, Edu,
##     edu_charge, edu_imp, edu_need, edu_time, harm, headcount, num,
##     part_1, part_2, part_3, part_4, place, recruit, rule_1, rule_2,
##     rule_3, rule_4, rule_5, rule_effect, sales, Sex, skill, smoke,
##     system_need, tail_29_1, tail_29_2, tail_29_3, tail_29_4, tail_29_5,
##     tail_31_1, tail_31_2, tail_31_3, tail_31_4, tail_31_5, Task, test,
##     year_no_1, year_no_2
df$Career1<-as.factor(df$Career1)
var.test(harm~Career1)
## 
##  F test to compare two variances
## 
## data:  harm by Career1
## F = 0.75453, num df = 44, denom df = 24, p-value = 0.41
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
##  0.3545198 1.4882062
## sample estimates:
## ratio of variances 
##          0.7545251
t.test(harm~Career1,var.equal=TRUE)
## 
##  Two Sample t-test
## 
## data:  harm by Career1
## t = -2.2026, df = 68, p-value = 0.03102
## alternative hypothesis: true difference in means between group 1 and group 4 is not equal to 0
## 95 percent confidence interval:
##  -0.95721593 -0.04722851
## sample estimates:
## mean in group 1 mean in group 4 
##        1.577778        2.080000