R geom_平铺、geom_文本和镶嵌面_包裹产生不正确的混淆矩阵
我的数据框如下所示:R geom_平铺、geom_文本和镶嵌面_包裹产生不正确的混淆矩阵,r,ggplot2,R,Ggplot2,我的数据框如下所示: method1 = c("cam","sce","cam","sce","cam","sce","cam","sce","cam","sce","cam","sce","cam","sce","cam","sce"); method2 = c("cam","cam","sce","sce","cam","cam","sce","sce","cam","cam","sce","sce","cam","cam","sce","sce"); p = c(0,0.191781,0.
method1 = c("cam","sce","cam","sce","cam","sce","cam","sce","cam","sce","cam","sce","cam","sce","cam","sce");
method2 = c("cam","cam","sce","sce","cam","cam","sce","sce","cam","cam","sce","sce","cam","cam","sce","sce");
p = c(0,0.191781,0.780822,0,0,0.082192,0.890411,0,0,0.383562,0.616438,0,0,0.054795,0.863014,0);
participant = c("LucO","LucO","LucO","LucO","ad","ad","ad","ad","arthur","arthur","arthur","arthur","evgeny","evgeny","evgeny","evgeny");
mydata = data.frame(method1,method2,p,participant);
我试图将每位参与者的困惑矩阵绘制为:
p <- ggplot( mydata, aes( x=method1, y=method2, fill=method2 ) ) +
geom_tile( aes( fill = mydata$p ) ) +
geom_text( aes( fill = mydata$p, label = round( mydata$p, 3 ) * 100 ) ) +
facet_wrap( ~participant, ncol=3, scales="free_x" );
p只需丢失mydata$p
并添加p
即可
函数的正确调用是:
library(ggplot2)
p <- ggplot( mydata, aes( x=method1, y=method2, fill=method2 ) ) +
geom_tile( aes( fill = p ) ) +
geom_text( aes( fill = p, label = round( p, 3 ) * 100 ) ) +
facet_wrap( ~participant, ncol=3, scales="free_x" );
p
> mydata
method1 method2 p participant
1 cam cam 0.000000 LucO
2 sce cam 0.191781 LucO
3 cam sce 0.780822 LucO
4 sce sce 0.000000 LucO
5 cam cam 0.000000 ad
6 sce cam 0.082192 ad
7 cam sce 0.890411 ad
8 sce sce 0.000000 ad
9 cam cam 0.000000 arthur
10 sce cam 0.383562 arthur
11 cam sce 0.616438 arthur
12 sce sce 0.000000 arthur
13 cam cam 0.000000 evgeny
14 sce cam 0.054795 evgeny
15 cam sce 0.863014 evgeny
16 sce sce 0.000000 evgeny