我有大量的列联表,其中一些只有一行和多列,大多数都有很多列。
如果我创建了列联表,以比较2个单独数据框中的值,那么创建一些图以可视化结果数据的最有效/最有效的方法是什么?
这里有两个数据框,一个包含所有求职者,一个仅包含成功者:
Id <- c(1,5,7,9,11,12,13,15,17,18)
Type <- c("Beginner", "Expert", "Intermediate", "Beginner",
"Professional", "Expert", "Intermediate", "Professional", "Professional",
"Expert")
Response<- c(0,1,2,2,1,2,1,2,1,1)
Successful <- data.frame(Id, Type, Response)
Successful
# Successful
Id Type Response
1 Beginner 0
5 Expert 1
7 Intermediate 2
9 Beginner 2
11 Professional 1
12 Expert 2
13 Intermediate 1
15 Professional 2
17 Professional 1
18 Expert 1
Id <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18)
Type <- c("Beginner", "Expert", "Professional", "Beginner", "Expert",
"Expert", "Intermediate", "Expert", "Beginner", "Intermediate",
"Professional", "Expert", "Intermediate","Intermediate", "Professional",
"Beginner", "Professional","Expert")
Response<- c(0,2,2,1,1,0,2,0,2,0,1,2,1,1,2,2,1,1)
AllApplicants <- data.frame(Id, Type, Response)
AllApplicants
# AllApplicants
Id Type Response
1 Beginner 0
2 Expert 2
3 Professional 2
4 Beginner 1
5 Expert 1
6 Expert 0
7 Intermediate 2
8 Expert 0
9 Beginner 2
10 Intermediate 0
11 Professional 1
12 Expert 2
13 Intermediate 1
14 Intermediate 1
15 Professional 2
16 Beginner 2
17 Professional 1
18 Expert 1
例如,我形成了以下三个列联表:
round(100*table(Successful$Type)/table(AllApplicants$Type), 3)
round(100*prop.table(table(AllApplicants$Response, AllApplicants$Type),2),
1)
round(100*prop.table(table(Successful$Response)), 1)
是否存在可以用来观察这些现象的绘图功能?如果是这样,我该如何输入数据? ggplot(例如geom_mosaic())往往只需要一个数据框...