I cannot order the y value!
Here is an example:
#Create a demo data set:
df2 <- data.frame(supp=rep(c("VC", "OJ"), each=3),
dose=rep(c("D0.5", "D1", "D2"),2),
len=c(6.8, 15, 33, 4.2, 10, 29.5))
print(df2)
## supp dose len
## 1 VC D0.5 6.8
## 2 VC D1 15.0
## 3 VC D2 33.0
## 4 OJ D0.5 4.2
## 5 OJ D1 10.0
## 6 OJ D2 29.5
#Plot y = “len” by x = “dose” and change color by a second group: “supp”
#Interleaved (dodged) bar plot
ggbarplot(df2, x = "dose", y = "len",
fill = "supp", color = "supp",
palette = c("gray", "black"),
position = position_dodge(0.9))
I added sort.val = "desc" to adjust the order of the y- value in the graphic:
ggbarplot(df2, x = "dose", y = "len",
fill = "supp", color = "supp",
palette = c("gray", "black"), sort.val = "desc" ,
position = position_dodge(0.9))
the result is an error:
Error in `levels<-`(`*tmp*`, value = as.character(levels)) :
factor level [4] is duplicated
What can I do?