Re: [R] Can this be done in ggplot?

2017-04-15 Thread Axel Urbiz
Thanks Kenneth. That is the right idea for what I’m after. However, creating a combined factor based on “g” and “f” is creating unwanted spaces between the bars in the plot (I’d like to keep them adjacent within levels of “g” as shown in my first plot). I had the idea that ordering bars in ggplot

Re: [R] Can this be done in ggplot?

2017-04-15 Thread Axel Urbiz
Thanks Kenneth. That is the right idea for what I’m after. However, creating a combined factor based on “g” and “f” is creating unwanted spaces between the bars in the plot (I’d like to keep them adjacent within levels of “g” as shown in my first plot). I had the idea that ordering bars in

Re: [R] Can this be done in ggplot?

2017-04-14 Thread Kenneth Roy Cabrera Torres
A very dirty solution. I hope someone can give a better solution: library(ggplot2) set.seed(1) df <- expand.grid(g = factor(1:4), f = factor(c("a", "b", "c"))) df <- df[-1, ] # some factors are not present in certain groups df$v <- runif(nrow(df)) library(dplyr) df <- df %>% arrange(g,

[R] Can this be done in ggplot?

2017-04-14 Thread Axel Urbiz
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,