R sql automate query (solution)

Exercise
Output solution
   species_id sex AVG(hindfoot_length) AVG(weight)
1          AH   M                   NA          NA
2          BA   F             13.16129    9.161290
3          BA   M             12.64286    7.357143
4          DM   F             35.71269   41.609685
5          DM   M             36.18823   44.353134
6          DO   F             35.48633   48.531250
7          DO   M             35.69878   49.135102
8          DS   F             49.58317  117.749548
9          DS   M             50.30194  122.290984
10         NL   F             32.02419  154.282209
11         NL   M             32.57743  165.652893
12         OL   F             20.28767   31.065817
13         OL   M             20.75833   32.068410
14         OT   F             20.28165   24.830904
15         OT   M             20.25740   23.695382
16         OX   F             19.66667   21.000000
17         OX   M             18.80000   21.000000
18         PB   F             25.88267   30.210884
19         PB   M             26.43199   33.816498
20         PE   F             20.27206   22.822183
21         PE   M             20.13213   20.584906
22         PF   F             15.55062    7.974394
23         PF   M             15.62078    7.885287
24         PH   F             25.90000   30.850000
25         PH   M             25.54545   31.454545
26         PI   M             22.50000   19.428571
27         PL   F             19.75000   19.312500
28         PL   M             20.26316   18.684211
29         PM   F             20.27978   22.125668
30         PM   M             20.53002   20.801205
31         PP   F             21.67662   17.180670
32         PP   M             21.83864   17.184486
33         PX   F             19.00000   20.000000
34         PX   M             20.00000   18.000000
35         RF   F             17.52727   13.684211
36         RF   M             17.50000   12.444444
37         RM   F             16.39188   11.102196
38         RM   M             16.49151   10.123226
39         RO   F             14.75000   11.000000
40         RO   M             16.00000    9.500000
41         RX   M             18.50000   15.500000
42         SF   F             27.50000   69.000000
43         SF   M             26.34783   53.434783
44         SH   F             29.02817   78.756410
45         SH   M             27.98333   65.177419
46         SO   F             25.63333   55.322581
47         SO   M             25.72727   55.700000
48         SS   F                   NA   57.000000
49         SS   M                   NA  130.000000