How to calculate fractions within parts of a cast dataframe?
===

As a result of melting and subsequent casting`[1]` a dataset I obtained the following array(?) (`sumStats.c`):


    , , group2 = G2_1, variable = area
    
                group1
    group3        G1_1      G1_2     G1_3       G1_4
       G3_1      0.000     0.000     0.00      0.000
       G3_2      0.000     0.000     0.00      0.000
       G3_3      0.000     0.000     0.00      0.000
       G3_4      0.000     0.000     0.00      0.000
       G3_5      0.000     0.000     0.00      0.000
       G3_6      0.000     0.000     0.00      0.000
       G3_7      0.000     0.000 26336.99  85236.488
       G3_8      0.000  4999.235 87935.73 360062.128
       G3_9      0.000     0.000     0.00      0.000
       G3_10  7853.982 18538.285 49744.29 134180.428
       G3_11     0.000     0.000     0.00   8830.825
       G3_12     0.000     0.000     0.00      0.000
    
       
    , , grou2 = G2_2, variable = area
    
             group1
    group3         G1_1     G1_2      G1_3      G1_4
       G3_1       0.000     0.00      0.00      0.00
       G3_2       0.000     0.00      0.00      0.00
       G3_3       0.000     0.00      0.00      0.00
       G3_4       0.000     0.00      0.00      0.00
       G3_5       0.000     0.00      0.00      0.00
       G3_6       0.000     0.00      0.00  51772.66
       G3_7       0.000     0.00      0.00      0.00
       G3_8    7853.982 22086.38 140874.76 523373.88
       G3_9       0.000     0.00      0.00      0.00
       G3_10      0.000  1415.79  23325.94  13407.49
       G3_11      0.000     0.00      0.00      0.00
       G3_12      0.000     0.00      0.00      0.00
    
       
    , , group2 = G2_3, variable = area
    
              group1
    group3          G1_1      G1_2       G1_3        G1_4
       G3_1       0.0000     0.000      0.000      0.0000
       G3_2       0.0000     0.000      0.000      0.0000
       G3_3       0.0000     0.000      0.000     93.2632
       G3_4       0.0000     0.000      0.000      0.0000
       G3_5       0.0000     0.000      0.000  46353.3814
       G3_6       0.0000     0.000      0.000      0.0000
       G3_7       0.0000     0.000      0.000      0.0000
       G3_8    7390.0570 16851.829 101013.680 232666.8839
       G3_9       0.0000  2541.574   6397.271  87825.7232
       G3_10      0.0000     0.000      0.000      0.0000
       G3_11    436.9895  4118.440  56572.140 173866.7915
       G3_12      0.0000     0.000      0.000  47924.5494
    

Now I need to get the _fraction_ of the variable (`area`) within each `group2` relative to the total of each `group1` across `group3`. So for example, G2_1 (`group2`) has 100% of G3_10 (`group3`) in G1_1 (`group1`), G1_2 (`group1`) has 21.24 % of G3_8 and 78.76 % of G3_10, and so forth. Once the percentages have been calculated for each column of `group1` I think that I can `melt()` the resulting arrays to get the dataframe needed for further analysis. 

I feel that `ddply()` would be helpful here but as I have a hard time understanding how to use it for the task at hand, I would appreciate if someone could help out.

    [1]
    sumStats.m <- melt(sumStats, id=c("group1", "group2", "group3"), "area")
    sumStats.c <- cast(sumStats.m, group3 ~ group1 ~ group2 ~ variable, sum)

