Việc 1: Đọc dữ liệu nghiên cứu Arrest dataset.csv và gọi
đối tượng là arr.
arr= read.csv ("D:\\OneDrive\\Statistical courses\\Can Tho University of Medicine_Sep2022\\Data for practice\\Arrest dataset.csv")
names (arr)
## [1] "id" "age" "finance" "week" "arrest" "race"
## [7] "work.exp" "married" "parole" "prior" "educ" "employ1"
Dùng table1::table1 để có cái nhìn chung về nghiên cứu
này:
table1::table1 (~ age + finance + race + work.exp + married + parole + prior + factor(educ)|arrest, data= arr)
## Warning in table1.formula(~age + finance + race + work.exp + married + parole
## + : Terms to the right of '|' in formula 'x' define table columns and are
## expected to be factors with meaningful labels.
| 0 (N=318) |
1 (N=114) |
Overall (N=432) |
|
|---|---|---|---|
| age | |||
| Mean (SD) | 25.3 (6.31) | 22.8 (5.12) | 24.6 (6.11) |
| Median [Min, Max] | 23.0 [17.0, 44.0] | 21.0 [17.0, 44.0] | 23.0 [17.0, 44.0] |
| finance | |||
| no | 150 (47.2%) | 66 (57.9%) | 216 (50.0%) |
| yes | 168 (52.8%) | 48 (42.1%) | 216 (50.0%) |
| race | |||
| black | 277 (87.1%) | 102 (89.5%) | 379 (87.7%) |
| other | 41 (12.9%) | 12 (10.5%) | 53 (12.3%) |
| work.exp | |||
| no | 123 (38.7%) | 62 (54.4%) | 185 (42.8%) |
| yes | 195 (61.3%) | 52 (45.6%) | 247 (57.2%) |
| married | |||
| married | 45 (14.2%) | 8 (7.0%) | 53 (12.3%) |
| not married | 273 (85.8%) | 106 (93.0%) | 379 (87.7%) |
| parole | |||
| no | 119 (37.4%) | 46 (40.4%) | 165 (38.2%) |
| yes | 199 (62.6%) | 68 (59.6%) | 267 (61.8%) |
| prior | |||
| Mean (SD) | 2.70 (2.55) | 3.77 (3.59) | 2.98 (2.90) |
| Median [Min, Max] | 2.00 [0, 15.0] | 3.00 [0, 18.0] | 2.00 [0, 18.0] |
| factor(educ) | |||
| 2 | 20 (6.3%) | 4 (3.5%) | 24 (5.6%) |
| 3 | 162 (50.9%) | 77 (67.5%) | 239 (55.3%) |
| 4 | 92 (28.9%) | 27 (23.7%) | 119 (27.5%) |
| 5 | 34 (10.7%) | 5 (4.4%) | 39 (9.0%) |
| 6 | 10 (3.1%) | 1 (0.9%) | 11 (2.5%) |