[R] Can this be done in ggplot?
Axel Urbiz
axel.urbiz at gmail.com
Fri Apr 14 17:08:47 CEST 2017
Hi,
I need to bars to display in order based on the values of "v" within each
group "g". Is this possible?
library(ggplot2)
set.seed(1)
df <- expand.grid(g = 1:4, f = factor(c("a", "b", "c")))
df <- df[-1, ] # some factors are not present in certain groups
df$v <- runif(nrow(df))
ggplot(df, aes(x = g, y = v, fill = f)) +
geom_bar(position="dodge", stat = "identity")
Thanks,
Axel.
[[alternative HTML version deleted]]
More information about the R-help
mailing list