I want to summarize several columns using facet_wrap. I want to give several of the facet panes long titles. For example:
set.seed(123)
df <- 
  data.frame(
    a = sample(0:1, 20, replace = T),
    b = sample(1:4, 20, replace = T)
  )
names <- list(
  "a" = "Nice table 1",
  "b" = "Here is a really long title that I would like to wrap within the facet pane")
labeller_fun <- 
  function(variable,value){
  return(names[value])
  }
ggplot(gather(df,, factor_key = TRUE), aes(x = factor(value))) + 
geom_bar() + 
facet_wrap(~ key, scales = "free_x", as.table = TRUE, labeller = labeller_fun) + 
xlab("")
Here, the long title spills over and is mostly invisible. Is there a way to wrap the long text automatically in the pane title box?
