问卷分析
cishan = cishan <- read.csv("C:/Users/Administrator.ZE1XUQWPNXEUCFB/Desktop/clean/R_Room/2.16/cishan.csv", stringsAsFactors=FALSE)
knitr::kable(head(cishan))
| y | x2 | x3 | x4 | x5 | x6 |
|---|---|---|---|---|---|
| 6 | 4 | 3 | 2 | 2 | 2 |
| 3 | 2 | 1 | 3 | 5 | 2 |
| 6 | 3 | 1 | 2 | 3 | 2 |
| 0 | 4 | 4 | 2 | 3 | 3 |
| 5 | 5 | 3 | 3 | 7 | 3 |
| 2 | 2 | 3 | 4 | 3 | 2 |
for(i in 2:6) {
cat("x",i, sep = "")
print(table(cishan[, i]))
print(aggregate(cishan[, 1], by = list(cishan[, i]), FUN = mean))
print(aggregate(cishan[, 1], by = list(cishan[, i]), FUN = sd))
fit = aov(cishan[, 1] ~ cishan[, i])
print(summary(fit))
for(j in 1:2) print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
}
## x2
## 1 2 3 4 5
## 27 246 300 208 245
## Group.1 x
## 1 1 3.111111
## 2 2 3.304878
## 3 3 3.023333
## 4 4 2.480769
## 5 5 2.820408
## Group.1 x
## 1 1 2.778120
## 2 2 2.376873
## 3 3 2.690772
## 4 4 2.723953
## 5 5 2.822696
## Df Sum Sq Mean Sq F value Pr(>F)
## cishan[, i] 1 45 45.41 6.398 0.0116 *
## Residuals 1024 7267 7.10
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## [1] "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
## [1] "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
## x3
## 1 2 3 4
## 466 219 296 45
## Group.1 x
## 1 1 2.695279
## 2 2 3.091324
## 3 3 3.341216
## 4 4 1.977778
## Group.1 x
## 1 1 2.824139
## 2 2 2.550565
## 3 3 2.381096
## 4 4 2.980916
## Df Sum Sq Mean Sq F value Pr(>F)
## cishan[, i] 1 23 22.709 3.19 0.0744 .
## Residuals 1024 7290 7.119
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## [1] "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
## [1] "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
## x4
## 1 2 3 4 5
## 113 227 291 330 65
## Group.1 x
## 1 1 2.663717
## 2 2 2.995595
## 3 3 3.189003
## 4 4 2.821212
## 5 5 2.630769
## Group.1 x
## 1 1 2.817707
## 2 2 2.648255
## 3 3 2.515198
## 4 4 2.823292
## 5 5 2.315500
## Df Sum Sq Mean Sq F value Pr(>F)
## cishan[, i] 1 1 0.688 0.096 0.756
## Residuals 1024 7312 7.141
## [1] "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
## [1] "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
## x5
## 1 2 3 4 5 6 7
## 58 166 258 73 157 121 193
## Group.1 x
## 1 1 3.758621
## 2 2 2.759036
## 3 3 2.693798
## 4 4 2.684932
## 5 5 3.082803
## 6 6 3.148760
## 7 7 3.000000
## Group.1 x
## 1 1 2.002720
## 2 2 2.647310
## 3 3 3.015402
## 4 4 2.618718
## 5 5 2.433637
## 6 6 2.444931
## 7 7 2.682893
## Df Sum Sq Mean Sq F value Pr(>F)
## cishan[, i] 1 2 2.143 0.3 0.584
## Residuals 1024 7310 7.139
## [1] "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
## [1] "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
## x6
## 1 2 3 4 5
## 141 474 253 138 20
## Group.1 x
## 1 1 2.943262
## 2 2 3.118143
## 3 3 2.810277
## 4 4 2.594203
## 5 5 2.450000
## Group.1 x
## 1 1 2.437133
## 2 2 2.665013
## 3 3 2.906542
## 4 4 2.542020
## 5 5 1.877148
## Df Sum Sq Mean Sq F value Pr(>F)
## cishan[, i] 1 26 26.071 3.664 0.0559 .
## Residuals 1024 7287 7.116
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## [1] "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
## [1] "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"