title: R: boxplot reorder differently in two facets
body: <p>I have measurements over two seasons (summer and winter) of one parameter:Formaldehyde with different sensors( A1, B2,B3,...F21).
  Data looks like this:</p>
  <pre><code>sensor=A1,A1,A2,A2,A3,A3
  Formaldehyde=21.3,34.2,55,66.3,70.8,90
  Season= summer,winter,summer,winter,summer,winter
  </code></pre>
  <p>I am trying to make a geom_boxplot divided into two facets( one for each season) and I want the sensors to be ordered by increasing median (independently in each season)
  I have tried:</p>
  <pre><code>fac &lt;- with(DATALL, reorder(sensor,Formaldehyde, median, order = TRUE))
  DATALL$sensors &lt;- factor(DATALL$sensor, levels = levels(fac))
  
  a &lt;- ggplot(DATALL,aes(sensors,Formaldehyde, fill=sensors)) + 
    geom_jitter(position=position_jitter(width=0.3, height=0.2), aes(colour=factor(sensors)), alpha=0.4) +
    geom_boxplot(outlier.shape = NA)+
    facet_wrap(~season, scales='free', ncol=1)+
    scale_y_continuous(limits = quantile(DATALL$Formaldehyde, c(0.1, 0.98)))
  a&lt;-a+labs(x=&quot;&quot;,y=expression(Formaldehyde~(30~min)~(µg/ m^{3})))+theme(legend.position = &quot;none&quot;)
  </code></pre>
  <p>But this orders the sensors considering the median of both seasons and not for each facet independently.
  Do you have any advice?</p>