vgrabovets
10/4/2016 - 10:12 AM

facets different order

facets different order

p = ggplot(subs, aes(reorder(title_admin, desc(qty)), qty)) +
     geom_bar(stat = "identity") +
     facet_wrap(~current_status, nrow = 1) +
     theme(axis.text.x = element_text(angle = -30, vjust = 1, hjust = 0))

#######
#gridExtra
library(gridExtra)
df_list <- split(subs,subs$current_status)
df_list <- lapply(df_list,function(x){x$title_admin <- reorder(x$title_admin,-x$qty); x})
p_list <- lapply(df_list,function(dat,plot){plot %+% dat},plot = p)
#do.call(grid.arrange,p_list)
marrangeGrob(p_list,nrow=1,ncol=2)