列をループして、以下のコードを使用して次のデータセットのカイ二乗検定を計算しようとしています
result=numeric(length(client-1))
for (i in 1:length(client-1)) {
result=chisq.test(table(client[[i]], client[[i+1]]))
}
私のデータセットのサンプルはこちら
sex mar_st education
1 Female c) Cohabiting e) Secondary form 3 to form 4
2 Female a) Married monogamous c) Primary 5 to 8
3 Female c) Cohabiting c) Primary 5 to 8
4 Male a) Married monogamous a) None (never attended school)
5 Male a) Married monogamous e) Secondary form 3 to form 4
6 Female d) Single f) Higher/tertiary (college/university)
7 Male d) Single f) Higher/tertiary (college/university)
8 Female a) Married monogamous e) Secondary form 3 to form 4
work Q6
1 d) Skilled manual
2 h) Unemployed
3 d) Skilled manual
4 g) Agriculture
5 i) Other (specify) Business man
6 h) Unemployed
7 h) Unemployed
8 h) Unemployed
次のエラー/警告が表示されます...
#Error in .subset2(x, i, exact = exact) : subscript out of bounds
#In addition: Warning messages:
#1: In Ops.factor(left, right) : - not meaningful for factors
誰か助けてくれませんか