[R] factor interaction boxplot ordering by median

Sergio Fonda
Sat, 05 Sep 2015 12:29:11 -0000

I would to visualize in boxplot a data frame with two factors ordering one
factor with the median.
As example,suppose to have the InsectSprays dataframe, where an
"operator"
factor with two levels, op1 and op2, has been added as shown at bottom here.
How may be generated a boxplot showing boxes for the interaction spray*op,
ordered according to the operators' count median for every spray ?
Thanks in advance for any help!
Sergio
________________________________
Modified InsectSprays dataframe:
   count spray  op
1     10     A op1
2      7     A op1
3     20     A op1
4     14     A op1
5     14     A op1
6     12     A op1
7     10     A op2
8     23     A op2
9     17     A op2
10    20     A op2
11    14     A op2
12    13     A op2
13    11     B op1
14    17     B op1
15    21     B op1
16    11     B op1
17    16     B op1
18    14     B op1
19    17     B op2
20    17     B op2
21    19     B op2
22    21     B op2
23     7     B op2
24    13     B op2
25     0     C op1
26     1     C op1
27     7     C op1
28     2     C op1
29     3     C op1
30     1     C op1
31     2     C op2
32     1     C op2
33     3     C op2
34     0     C op2
35     1     C op2
36     4     C op2
37     3     D op1
38     5     D op1
39    12     D op1
40     6     D op1
41     4     D op1
42     3     D op1
43     5     D op2
44     5     D op2
45     5     D op2
46     5     D op2
47     2     D op2
48     4     D op2
49     3     E op1
50     5     E op1
51     3     E op1
52     5     E op1
53     3     E op1
54     6     E op1
55     1     E op2
56     1     E op2
57     3     E op2
58     2     E op2
59     6     E op2
60     4     E op2
61    11     F op1
62     9     F op1
63    15     F op1
64    22     F op1
65    15     F op1
66    16     F op1
67    13     F op2
68    10     F op2
69    26     F op2
70    26     F op2
71    24     F op2
72    13     F op2