能否请您看一下这段代码,让我知道如何重新排序以蔗糖,p:c,p:c + u,p:c:l + u开头的级别?还有传奇故事也要从对照组开始?
这是我的代码:
Nutrient <- as.factor(c("s", "p:c", "p:c+u", "p:c:l+u"))
Nutrientlevels<-c("s", "p:c", "p:c+u", "p:c:l+u")
levels(Nutrient) <- Nutrientlevels
ggplot(df,aes(x = Nutrient, y = Consumption),levels)+
geom_bar(aes(fill = Diet), stat = "identity",position = "dodge")+
scale_fill_brewer(palette="Set3")+
levels(Nutrient)+
xlab("Nutrient")+
ylab("Average consumption (mg)")+
ggtitle("Average daily consumption")+
theme(panel.grid.major = element_blank(), panel.grid.minor =
element_blank(),panel.background = element_blank(), axis.line =
element_line(colour = "black"))+
guides(color=guide_legend(override.aes=list(fill=NA)))+
theme_bw() +
theme(panel.border = element_blank(), panel.grid.major =
element_blank(),panel.grid.minor = element_blank(),
axis.line = element_line(colour="black"))+
theme(plot.title = element_text(hjust = 0.5))
非常感谢
答案 0 :(得分:0)
也许这行得通吗?
营养水平<-排序(“ s”,“ p:c”,“ p:c + u”,“ p:c:l + u”)