我的R数据帧中有2个因子变量和1个逻辑变量:
> table(eaos$GM, eaos$CONTRACTOR.FLAG)
N Y
Belfast 1145 0
East Anglia 7969 207
London 7583 232
North East 8378 113
North Wales & North Midlands 9852 91
North West 8124 130
Province 1128 0
Scotland 7804 105
South East 7309 115
South Wales & South Midlands 6991 140
Unkn 20 0
Wessex 8116 209
上表显示了我的业务部门以及是否有任何承包商在该补丁中工作。
第3栏看起来像这样:
> table(eaos$GM,eaos$EARLY)
FALSE TRUE
Belfast 458 31
East Anglia 1810 268
London 2074 338
North East 2437 467
North Wales & North Midlands 2177 415
North West 1461 347
Province 447 41
Scotland 1352 278
South East 1460 292
South Wales & South Midlands 1707 315
Unkn 2 0
Wessex 2042 301
此表显示工程师是否提前到达现场。 我想打印一下,看看contractor.flag是否是,他/她是否提前到达或者没有达到以下格式:
> table(eaos$GM,eaos$EARLY)
TRUE Contractor.FLAG
Belfast 31 0
East Anglia 268 110
London 338 210
North East 467 100
North Wales & North Midlands 415 90
North West 347 100
Province 41 0
Scotland 278 101
South East 292 110
South Wales & South Midlands 315 130
Unkn 0 0
Wessex 301 209
任何帮助都将受到高度赞赏。
答案 0 :(得分:0)
我可以按照rawr
的建议使用ftable进行打印> ftable(eaos$GM,eaos$EARLY, eaos$CONTRACTOR.FLAG)
N Y
Belfast FALSE 458 0
TRUE 31 0
East Anglia FALSE 1717 93
TRUE 267 1
London FALSE 1991 83
TRUE 335 3
North East FALSE 2377 60
TRUE 466 1
North Wales & North Midlands FALSE 2133 44
TRUE 411 4
North West FALSE 1410 51
TRUE 346 1
Province FALSE 447 0
TRUE 41 0
Scotland FALSE 1299 53
TRUE 275 3
South East FALSE 1417 43
TRUE 289 3
South Wales & South Midlands FALSE 1647 60
TRUE 314 1
Unkn FALSE 2 0
TRUE 0 0
Wessex FALSE 1926 116
TRUE 295 6
每个GM补丁发生故障。检查是否提前到达(真/假)并检查承包商标志(N / Y)