数据:
> library(vcd) > head(Arthritis) ID Treatment Sex Age Improved 1 57 Treated Male 27 Some 2 46 Treated Male 29 None 3 77 Treated Male 30 None 4 17 Treated Male 32 Marked 5 36 Treated Male 46 Marked 6 23 Treated Male 58 Marked >
1. 生成频数表
1.1 一维列联表
> mytable <- with(Arthritis, table(Improved)) > mytable Improved None Some Marked 42 14 28 > prop.table(mytable) Improved None Some Marked 0.5000000 0.1666667 0.3333333 > prop.table(mytable)*100 Improved None Some Marked 50.00000 16.66667 33.33333 >
1.2 二维列联表