I have created a contingency table with several variables/cols by 510 categories/factors. I want to have factors ordered descending based on the sum of all variables/cols.
Tried converting table back to DF and rowSums but no luck. Not sure if possible to sort while using table function?
DF structure
'data.frame': 2210 obs. of 7 variables:
$ Paddock_ID: num 1 1 1 1 1 1 1 1 1 1 ...
$ Year : num 2010 2011 2011 2012 2012 ...
$ LandUse : chr "Wheat" "Wheat" "Wheat" "Wheat" ...
$ LUT : chr "Cer" "Cer" "Cer" "Cer" ...
$ LUG : chr "Wheat" "Wheat" "Wheat" "Wheat" ...
$ Tmix : Factor w/ 6 levels "6","5","4","3",..: 6 5 6 4 6 5 4 5 6 6
...
$ combo : Factor w/ 510 levels "","GLYPHOSATE",..: 416 6 59 119 30
22 510 2 2 509
my table
a <- table(DF$"combo", DF$"LUG")
I get table ok but would like to have it ordered based on sum of all variables/columns i.e. Glyphosate = 124, then clethodim = 69, then paraquat = 53 ... descending for all 510 categories (rows).
Barley Canola Lupin Other Pasture Wheat
GLYPHOSATE 4 46 6 5 23 40
TRALKOXYDIM 0 0 0 0 0 8
MCPA; GLYPHOSATE; METSULFURON 0 0 0 0 0 1
METSULFURON 1 0 0 0 0 1
BUTROXYDIM; METSULFURON 1 0 0 0 0 0
GLYPHOSATE; METSULFURON; PYRAFLUFEN 0 0 0 0 0 1
PARAQUAT 2 7 7 2 28 7
CLETHODIM 0 41 15 3 0 0