这段代码相当少,应该能够调整为解决方案。
blah <- data.frame(X1=c("Decrease Risk","Don't Know","Increase Risk","No Effect","Decrease Risk","Don't Know","Increase Risk","No Effect"),
X2=c("Red Meat","Red Meat","Red Meat","Red Meat","Red Meat","Red Meat","Red Meat","Red Meat"),
value=c(1.98,31.19,64.38,2.43,4.65,24.55,35.88,34.90),
status=c("Case","Case","Case","Case","Control","Control","Control","Control")
)
ggplot(blah, aes(X2, value, fill=X1)) + geom_bar() + coord_flip() + facet_wrap(~status) +
labs(x="Perceived Risk Factors", y="Percentage (%)", tilte="Some Title", fill="Responses")
我想要的是右侧的“控件”将“响应”级别的顺序颠倒过来。关键是,对于控件,紫色在里面,然后是蓝色的,然后是绿色的,外面是粉红色的。在这样的情节中这样做是半常见的,我可以想办法做到这一点,包括一些相当肮脏的变量重复和有序因子水平的改变,但认为有人可能有一个优雅的解决方案/想法?