title: How do I get subscript in ggplot2 facet grid labels when I have two faceting variables?
body: <p>I am trying to change one of the labels in my facet grid to contain some subscript text. I have been looking on stack overflow but none of the solutions work/I cannot understand how others are functioning so cannot apply them to my own scenario</p>
  
  <p>This is my current ggplot function:</p>
  
  <pre><code>FacetGridTest &lt;- tss_profiles %&gt;% group_by(pulldown, Condition, replicate, category) %&gt;%
      group_by(pulldown,Condition,category,region_bin, region) %&gt;%
    mutate(meannone = mean(none)) %&gt;%
    ungroup() %&gt;% 
    mutate(cond_cat=factor(cond_cat, levels=c("IG Target","IG Non-Target","MH Target","PH Target","MH Non-Target","PH Non-Target"))) %&gt;%
     mutate(category=factor(category, levels=c("Target","Non-Target"))) %&gt;%
    ggplot() + aes(x=Bin, y=meannone, col=Condition, group=paste(pulldown, Condition, replicate, category)) +
    geom_line() +
    facet_grid(pulldown~category, scale="free_x") +
    theme_bw(base_size = 10) +
    theme(legend.text.align = 0) +
  labs(y=expression(paste("Read Counts")),
       x=expression(paste("Bin"))) + 
    scale_colour_discrete(name = "Condition", labels = c("A","B","C"))  + 
    geom_vline(xintercept=6000, linetype="dotted")  +
    annotate("text", x = 1000, y = 8800, label = "TSS", size=3) +
    annotate("text", x = 11000, y = 8800, label = "TTS", size=3)
  </code></pre>
  
  <p>I want to change the "Non-Target" label to "J<sub>2</sub>L<sub>2</sub> Non-Target<sub>20</sub>+"</p>
  
  <p>Based on what I have seen on stack overflow I have tried doing:</p>
  
  <pre><code>vnames &lt;- list('Target' = 'Target',
  'Non-Target' = expression(paste("J" ["2"], "L" ["2"], " Non-Target" ["20"], "+")))
  bnames &lt;- list('A' = 'A','B' = 'B')
  
  plot_labeller &lt;- function(variable,value){
    if (variable=='category') {
      return(vnames[value])
    } else if (variable=='pulldown') {
      return(bnames[value])
    } else {
      return(as.character(value))
    }
  }
  
  tss_profiles %&gt;% group_by(pulldown, Condition, replicate, category) %&gt;%
      group_by(pulldown,Condition,category,region_bin, region) %&gt;%
    mutate(meannone = mean(none)) %&gt;%
    ungroup() %&gt;% 
    mutate(cond_cat=factor(cond_cat, levels=c("IG Target","IG Non-Target","MH Target","PH Target","MH Non-Target","PH Non-Target"))) %&gt;%
     mutate(category=factor(category, levels=c("Target","Non-Target"))) %&gt;%
    ggplot() + aes(x=Bin, y=meannone, col=Condition, group=paste(pulldown, Condition, replicate, category)) +
    geom_line() +
    facet_grid(pulldown~category, scale="free_x", plot_labeller) +
    theme_bw(base_size = 10) +
    theme(legend.text.align = 0) +
  labs(y=expression(paste("Read Counts")),
       x=expression(paste("Bin"))) + 
    scale_colour_discrete(name = "Condition", labels = c("A","B","C"))  + 
    geom_vline(xintercept=6000, linetype="dotted")  +
    annotate("text", x = 1000, y = 8800, label = "TSS", size=3) +
    annotate("text", x = 11000, y = 8800, label = "TTS", size=3)
  </code></pre>
  
  <p>But this has not worked. I am probably misunderstanding how labellers work. Any help would be much appreciated.</p>