在堆叠条形图中绘制卡方值

时间:2020-05-20 13:39:13

标签: ggplot2 stacked-chart p-value

给出了以下数据集

df <- data.frame(ID = c("AA","BB","CC","AA","BB","CC","AA","BB","CC","AA","BB","CC","AA","BB","CC"), percentages = c(10.4,0.19,89.41,12.05,0.78,87.17,2.92,0.1,96.99,14.19,1.07,84.74,48.59,28.4,22.93), Antibodies= c("positive","positive","positive","positive", "positive","positive","positive","positive","negative","negative","negative","negative","negative", "negative","negative"), BB= c( "cardio1","cardio2", "cardio3","cardio1","cardio2", "cardio3", "cardio1", "cardio2",  "cardio3", "cardio1", "cardio1", "cardio2","cardio3", "cardio1","cardio2"), stringsAsFactors = F)

我想在下图中绘制每个正负对的卡方值

ggplot(df,aes(x=Antibodies,y= percentages,fill=ID))+
  geom_bar(stat = "identity",color="white")+
  facet_wrap(~BB,nrow=1) 

enter image description here 我怎样才能做到这一点?

谢谢!

0 个答案:

没有答案