df<-read.csv("df.csv")
names(df)
##  [1] "num"         "headcount"   "composition" "Sex"         "Age"        
##  [6] "Career"      "Task"        "Edu"         "smoke"       "disease"    
## [11] "harm"        "edu_imp"     "edu_charge"  "edu_time"    "edu_need"   
## [16] "test"        "place"       "clean_use"   "clean_no"    "clean"      
## [21] "skill"       "recruit"     "system_need" "rule_1"      "rule_2"     
## [26] "rule_3"      "rule_4"      "rule_5"      "tail_29_1"   "tail_29_2"  
## [31] "tail_29_3"   "tail_29_4"   "tail_29_5"   "comply_1"    "comply_2"   
## [36] "comply_3"    "comply_4"    "comply_5"    "tail_31_1"   "tail_31_2"  
## [41] "tail_31_3"   "tail_31_4"   "tail_31_5"   "rule_effect" "sales"      
## [46] "year_no_1"   "year_no_2"   "part_1"      "part_2"      "part_3"     
## [51] "part_4"
df1<-df[,c(8,11)]
str(df1)
## 'data.frame':    114 obs. of  2 variables:
##  $ Edu : int  3 3 3 2 2 3 2 2 3 3 ...
##  $ harm: int  1 1 2 2 2 5 2 1 1 1 ...
df1$Edu<-as.factor(df1$Edu)
table(df1$Edu)
## 
##  1  2  3  4 99 
##  1 45 64  3  1
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5     v purrr   0.3.4
## v tibble  3.1.2     v dplyr   1.0.6
## v tidyr   1.2.0     v stringr 1.4.0
## v readr   1.4.0     v forcats 0.5.1
## Warning: 패키지 'ggplot2'는 R 버전 4.1.3에서 작성되었습니다
## Warning: 패키지 'tidyr'는 R 버전 4.1.3에서 작성되었습니다
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
df2<-df1 %>% filter(Edu!="99")
summary(df2)
##  Edu          harm      
##  1 : 1   Min.   :1.000  
##  2 :45   1st Qu.:1.000  
##  3 :64   Median :2.000  
##  4 : 3   Mean   :1.841  
##  99: 0   3rd Qu.:2.000  
##          Max.   :5.000
g4.out1<-lm(harm~Edu,data=df2)
anova(g4.out1)
## Analysis of Variance Table
## 
## Response: harm
##            Df  Sum Sq Mean Sq F value Pr(>F)
## Edu         3   0.888  0.2961  0.2557 0.8572
## Residuals 109 126.244  1.1582