I have problem to keep the original order in ggplot's geom_bar
plot while faceting. Found some online help but they did not work when I tried to facet.
Code:
df <- as.data.frame(cbind(x =rep(c("N-on", "N-off", "R-on", "R-off"),2),
y = c(13,6,7,11,20,16,17,19), z = c(rep("A", 4), rep("B", 4))))
ggplot(data=df, aes(x=x, y=y)) +
geom_bar(stat="identity") +
facet_wrap(~ z, ncol =1) +
coord_flip()
Expected output: Labels in the vertical axis will be in original order e.g., "N-on", "N-off", "R-on", "R-off".