#과제2-2(범주형 자료분석)

#install.packages("MASS")
#library(MASS)
#data(survey)
# 분할표 작성 방법 xtabs( ) 함수 사용 ~ 변수1, 변수2
# 성별(Sex)과 운동(Exer) 관계는 독립적인가?
#df<-xtabs(~Sex+Exer,data=survey)
#chisq.test(df)

library(MASS)
data(survey)
df<-xtabs(~Sex+Exer,data=survey)
chisq.test(df)
## 
##  Pearson's Chi-squared test
## 
## data:  df
## X-squared = 5.7184, df = 2, p-value = 0.05731
#결과 : p-value : 0.05731> 0.05 : 귀무가설 채택
#성별과 운동의 관계는 독립적이다.