Reorder barplot after gather() in ggplot()

rstudio

#1

Hello,

After I use gather() to tidy my data frame, how can I reorder the numeric values in based on "Total_PL_Sales"?

library(tidyverse) 
library(scales) 
#> 
#> Attaching package: 'scales'
#> The following object is masked from 'package:purrr':
#> 
#>     discard
#> The following object is masked from 'package:readr':
#> 
#>     col_factor
library(forcats) 
library(dplyr)
library(ggplot2)
library(data.table)
#> 
#> Attaching package: 'data.table'
#> The following objects are masked from 'package:dplyr':
#> 
#>     between, first, last
#> The following object is masked from 'package:purrr':
#> 
#>     transpose
library(reprex)

df8e = structure(list(ITEM_CATEGORY_DESCR = structure(c(2L, 7L, 12L, 
                                                        19L, 21L, 22L, 25L, 27L, 28L, 40L, 44L, 46L, 48L, 50L, 55L, 59L, 
                                                        77L, 78L, 79L, 109L, 118L, 134L, 140L, 161L, 164L, 167L, 178L, 
                                                        191L, 202L, 225L, 226L, 228L, 243L, 252L, 260L, 307L, 316L, 320L, 
                                                        352L, 404L, 431L, 432L, 437L, 438L, 450L, 452L, 459L, 472L, 477L, 
                                                        478L), .Label = c("ABRASIVE AND POLISHING MATERIAL", "ABSORBABLE SUTURE AND NEEDLE COMBINATION", 
                                                                          "ABSORBENT PAPER POINTS", "ADHESIVES EXTRAORAL", "AIR ABRASION", 
                                                                          "AIR FRESHENERS", "AIR/WATER SYRINGE TIPS DISPOSABLE", "AIR/WATER SYRINGE TIPS METAL", 
                                                                          "AIR/WATER SYRINGES", "ALCOHOL AND DISPENSERS", "ALLOY - MISCELLANEOUS", 
                                                                          "AMALGAM CAPSULES", "AMALGAM CARRIER PARTS", "AMALGAM CARRIERS", 
                                                                          "AMALGAM PELLETS", "AMALGAM PLUGGERS", "AMALGAM POWDER", "AMALGAMATORS AND PARTS", 
                                                                          "ANESTHETIC INJECTION ARTICAINE", "ANESTHETIC INJECTION BUPIVACAINE", 
                                                                          "ANESTHETIC INJECTION LIDOCAINE", "ANESTHETIC INJECTION MEPIVACAINE", 
                                                                          "ANESTHETIC INJECTION PRILOCAINE", "ANESTHETIC MISCELLANEOUS", 
                                                                          "ANESTHETIC NEEDLES", "ANESTHETIC SYRINGE AND ACCESSORIES", "ANESTHETIC TOPICAL", 
                                                                          "ANGLES PROPHY DISPOSABLE", "ANGLES PROPHY METAL", "APEX LOCATORS AND PULP TESTERS AND ACCESSORIES", 
                                                                          "APP-DISPENS AND MIX ACCESSORIES MISCELLANEOUS", "APPLICATOR BRUSHES AND BRUSH TIPS", 
                                                                          "APRONS OPERATORY AND PATIENT", "ARBOR BANDS", "ARTICULATING MISCELLANEOUS", 
                                                                          "ARTICULATING PAPER", "ARTICULATING PAPER FORCEPS", "ARTICULATING SILK AND ARTICULATING FILM", 
                                                                          "ARTICULATORS AND ACCESSORIES", "ASPIRATOR TIPS DISPOSABLE", 
                                                                          "ASPIRATOR TIPS NON DISPOSABLE", "AUTOCLAVE ACCESSORIES", "AUTOCLAVE BAGS PAPER", 
                                                                          "AUTOCLAVE POUCHES", "AUTOCLAVE TAPE", "AUTOCLAVE TEST STRIPS", 
                                                                          "AUTOCLAVE TUBING", "AUTOCLAVE WRAP", "BANDS COPPER", "BARRIER COVERS", 
                                                                          "BASE PLATES", "BASEPLATE WAX", "BASES AND LINERS", "BIOHAZARD WASTE BAGS AND CONTAINERS", 
                                                                          "BITE REGISTRATION MATERIAL", "BITE TRAYS", "BLEACHING ACCESSORIES", 
                                                                          "BLEACHING IN OFFICE", "BLEACHING TAKE HOME", "BLOOD PRESSURE MONITORS", 
                                                                          "BONDING AGENTS AND ADHESIVES MISCELLANEOUS", "BONDING MULTIPLE COMPONENT SEPARATE ETCH", 
                                                                          "BONDING SELF ETCHING", "BONDING SINGLE COMPONENT SEPARATE ETCH", 
                                                                          "BONE MANAGEMENT PRODUCTS", "BONE REGENERATION MATERIAL", "BOXING WAX", 
                                                                          "BRANCH CREATED NON-STOCK ITEMS ONLY", "BROACHES", "BRUSH WHEELS", 
                                                                          "BRUSHES POWER ASSISTED", "BUR HOLDERS", "BUR TOOLS", "BURNERS AND TORCHES", 
                                                                          "BURNISHERS", "BURS CARBIDE SPECIALTY", "BURS CARBIDE STANDARD", 
                                                                          "BURS CARBIDE SURGICAL", "BURS CARBIDE TRIMMING AND FINISHING", 
                                                                          "BURS ENDODONTIC", "BURS LAB", "BURS MISCELLANEOUS", "BURS STEEL STANDARD", 
                                                                          "BURS STEEL TRIMMING AND FINISHING", "CAD/CAM CUTTING INSTRUMENTS", 
                                                                          "CAD/CAM MISCELLANEOUS", "CAD/CAM OPTICAL MATERIALS", "CAD/CAM STAINS AND GLAZES", 
                                                                          "CAD/CAM, LABORATORY", "CAD/CAM, OPERATORY", "CAMERA MISCELLANEOUS", 
                                                                          "CANCER SCREENING DEVICES AND PRODUCTS", "CAPNOGRAPHY", "CAPSULES AND PESTLES", 
                                                                          "CARIES DETECTOR", "CARVERS", "CASSETTES AND ACCESSORIES", "CASSETTES AND SCREENS", 
                                                                          "CASTING ACCESSORIES", "CASTING WAX", "CEMENT CONVENTIONAL", 
                                                                          "CEMENT ENDODONTIC", "CEMENT GLASS IONOMER LUTING", "CEMENT MISCELLANEOUS", 
                                                                          "CEMENT ORTHODONTIC", "CEMENT RESIN", "CEMENT TEMPORARY", "CERAMIC MISCELLANEOUS", 
                                                                          "CHLORHEXIDINE GLUCONATE AND PERIO RINSES", "CHUCKS FOR HANDPIECE", 
                                                                          "CLEANER LUBRICANT FOR HANDPIECE", "CLEANERS (NON-DISINFECTING)", 
                                                                          "CLINICAL SUPPLIES", "COLD/HOT PACKS", "COLOR CODE TAPE AND RINGS", 
                                                                          "COMPOMERS", "COMPOSITE AND PLASTIC FILLING INSTRUMENTS", "COMPOSITE FLOWABLE", 
                                                                          "COMPOSITE GLAZES AND SEALERS", "COMPOSITE INDIRECT", "COMPOSITE PACKABLE", 
                                                                          "COMPOSITE TINTS AND OPAQUERS", "COMPOSITE UNIVERSAL", "CONTROLLED SCHEDULE 2 MEDICATIONS", 
                                                                          "CONTROLLED SCHEDULE 3 MEDICATIONS", "CONTROLLED SCHEDULE 4 MEDICATIONS", 
                                                                          "CONTROLLED SCHEDULE 5 MEDICATIONS", "CORE BUILD-UP", "COTTON PELLETS", 
                                                                          "COTTON PLIERS", "COTTON PRODUCTS MISCELLANEOUS", "COTTON ROLL ALTERNATIVES", 
                                                                          "COTTON ROLL HOLDERS & DISPENSERS", "COTTON ROLLS", "COTTON TIPS", 
                                                                          "CROWN AND BRIDGE REMOVERS", "CROWNS METAL", "CROWNS PLASTIC", 
                                                                          "CROWNS, BANDS AND SHELLS MISCELLANEOUS", "CUPS DRINKING", "CURING LIGHT BULBS", 
                                                                          "CURING LIGHT EYE PROTECTION", "CURING LIGHT GUIDES TIPS", "CURING LIGHT HALOGEN", 
                                                                          "CURING LIGHT LED", "CURING LIGHT MISCELLANEOUS", "CUTTING INSTRUMENTS", 
                                                                          "DAPPEN DISHES", "DARK ROOM LIGHTS AND FILTERS", "DEFIBRILLATOR ACCESSORIES", 
                                                                          "DENTAL FLOSS", "DENTURE BASE MATERIAL", "DENTURE LINER AND CONDITIONER", 
                                                                          "DENTURE MATERIAL MISCELLANEOUS", "DENTURE REPAIR MATERIAL", 
                                                                          "DESENSITIZERS", "DEVELOPING TANKS AND ACCESSORIES", "DIAMOND DISCS", 
                                                                          "DIAMOND DISPOSABLE", "DIAMOND MISCELLANEOUS", "DIAMOND STANDARD", 
                                                                          "DIE SPACERS AND LUBRICANTS", "DIGITAL IMAGING PLATES AND GUIDES", 
                                                                          "DIGITAL SENSOR SHEATHS", "DISCLOSING AGENTS", "DISPENSERS AND DISPENSING GUNS", 
                                                                          "DISPOSABLE ENDO-IRRIGATION-IMPRESSION SYRINGES", "DOWEL PINS", 
                                                                          "DRAPES", "DRY SOCKET TREATMENT", "DUPLICATING MATERIALS", "ELECTROSURG AND ACCESSORIES", 
                                                                          "ELEVATORS", "ENDO AND IRRIGATION SYRINGE NEEDLES", "ENDO SHAPER", 
                                                                          "ENDODONTIC DRILLS", "ENDODONTIC GAUGES AND RULERS", "ENDODONTIC HAND FILES", 
                                                                          "ENDODONTIC HANDPIECES", "ENDODONTIC MEDICAMENTS", "ENDODONTIC MISCELLANEOUS", 
                                                                          "ENDODONTIC ORGANIZERS AND ACCESSORIES", "ENDODONTIC PLUGGERS AND SPREADERS", 
                                                                          "ENDODONTIC REAMERS", "ENDODONTIC ROTARY FILES", "ENDODONTIC STOPS", 
                                                                          "ENGINE BELTS", "ENZYME CLEANERS", "ETCHANT TIPS", "ETCHANTS EXTRAORAL", 
                                                                          "ETCHANTS INTRAORAL", "EUGENOL", "EVACUATION CLEANERS", "EVACUATION CLEANERS MISC.", 
                                                                          "EVACUATION TRAPS", "EXCAVATORS", "EXPLORERS", "EXPROS OR EXPLORER-PROBES", 
                                                                          "EYE GLASSES", "EYE WASH STATIONS AND ACCESSORIES", "FACE SHIELDS", 
                                                                          "FACEMASKS", "FACIAL TISSUE", "FELT CONES AND WHEELS", "FIBRE OPTIC AND CURING LIGHT BULBS", 
                                                                          "FILES OPERATIVE", "FILM PAPER", "FINISHING AND POLISHING MISC", 
                                                                          "FINISHING DISCS", "FINISHING STRIPS", "FIRE EXTINGUISHERS", 
                                                                          "FIRST AID PRODUCTS", "FLASKS AND PRESSES", "FLOSS AIDS AND FLOSSERS", 
                                                                          "FLOSS DISPENSERS", "FLUORIDE HOME USE", "FLUORIDE IN-OFFICE", 
                                                                          "FLUORIDE TRAYS", "FLUORIDE VARNISHES", "FORCEPS, EXTRACTING", 
                                                                          "FURNACE TRAYS AND PILLOWS", "GENERAL CLEANING MISCELLANOUS", 
                                                                          "GLASS IONOMER RESTORATIVES", "GLOVE DISPENSERS", "GLOVES CHLOROPRENE", 
                                                                          "GLOVES LATEX", "GLOVES MISCELLANEOUS", "GLOVES NITRILE", "GLOVES SURGICAL", 
                                                                          "GLOVES VINYL", "GUTTA PERCHA POINTS", "GYPSUM", "GYPSUMS AND INVESTMENTS MISC.", 
                                                                          "HAND MIRRORS", "HAND TOWEL DISPENSERS", "HAND TOWELS", "HANDPIECE AND ANGLE MISCELLANEOUS", 
                                                                          "HANDPIECE CLEANER", "HANDPIECE COMPONENTS", "HANDPIECE ELECTRIC", 
                                                                          "HANDPIECE PARTS", "HEADLAMPS", "HEADREST COVERS", "HEMOSTATS", 
                                                                          "HIGH SPEED HANDPIECES, AIR", "HVE TIP ACCESSORIES", "HVE TIPS DISPOSABLE", 
                                                                          "HVE TIPS NON DISPOSABLE", "IMPLANT CLEANING INSTRUMENT", "IMPLANT WRENCHES AND ACCESSORIES", 
                                                                          "IMPLANTS", "IMPRESSION MATERIAL ALGINATE", "IMPRESSION MATERIAL ALGINATE SUBSTITUTE", 
                                                                          "IMPRESSION MATERIAL COMPOUND", "IMPRESSION MATERIAL HYDROCOLLOID", 
                                                                          "IMPRESSION MATERIAL MISCELLANEOUS", "IMPRESSION MATERIAL POLYETHER", 
                                                                          "IMPRESSION MATERIAL RUBBER BASE", "IMPRESSION MATERIAL SILICONE", 
                                                                          "IMPRESSION MATERIAL VINYL POLYSILOXANE", "IMPRESSION MATERIAL ZOE", 
                                                                          "INFECTION CONTROL MISCELLANEOUS", "INFORMATIONAL ITEMS", "INFORMATIONAL ONLY ITEMS (NOT ACTUAL PRODUCTS)", 
                                                                          "INSTRUMENT MATS", "INSTRUMENTS MISCELLANEOUS", "INTERDENTAL CLEANERS", 
                                                                          "INTERNAL USE ONLY (PROMOS, FEES...)", "INTRAORAL CAMERA SHEATHS", 
                                                                          "INVESTMENT", "IV SETS", "IV SOLUTIONS", "Inserted by Trigger 04/03/00", 
                                                                          "LAB ALLOY AND ACCESSORIES", "LAB BRUSHES", "LAB CHISELS AND SCRAPERS", 
                                                                          "LAB DIAMONDS", "LAB HANDPIECES, AIR DRIVEN", "LAB HANDPIECES, BELT DRIVEN", 
                                                                          "LAB HANDPIECES, ELECTRIC", "LAB INSTRUMENTS AND TOOLS MISC.", 
                                                                          "LAB KNIVES", "LAB MISCELLANEOUS", "LAB SCISSORS", "LAB SPATULAS", 
                                                                          "LAB WAXING INSTRUMENTS", "LABORATORY DISCS, NON-CERAMIC", "LATHE CHUCKS", 
                                                                          "LATHE WHEELS", "LIGHT BULBS MISCELLANEOUS", "LOTIONS", "LOUPES AND MAGNIFIERS", 
                                                                          "LOW SPEED HANDPIECES, AIR", "MANDRELS", "MATRIX AND WEDGES MISCELLANEOUS", 
                                                                          "MATRIX BANDS METAL", "MATRIX RETAINER", "MATRIX STRIPS PLASTIC", 
                                                                          "MEASURING GAUGES LAB TYPE", "MEDICAMENT MISCELLANEOUS", "MERCURY AND ACCESSORIES", 
                                                                          "METAL IMPRESSION MATERIAL SYRINGES", "MIRROR DEFOGGERS", "MIRROR HANDLES", 
                                                                          "MIRROR MISCELLANEOUS", "MISCELLANEOUS-MISCELLANEOUS", "MIXING AND INTRAORAL TIPS", 
                                                                          "MIXING BOWLS", "MIXING PADS AND GLASS SLABS", "MIXING SPATULAS", 
                                                                          "MIXING WELLS", "MODEL TRIMMER WHEELS AND ACCESSORIES", "MONITORING BADGES", 
                                                                          "MOUNTED STONES", "MOUTH MIRRORS LIGHTED", "MOUTH MIRRORS METAL", 
                                                                          "MOUTH MIRRORS PLASTIC", "MOUTH PROPS", "MOUTHWASH AND RINSES", 
                                                                          "MULTIPURPOSE DISPENSING & APPLICATOR TIPS", "MUSLIN BUFF WHEELS", 
                                                                          "NAPKIN HOLDERS - BIB CLIPS", "NEEDLE CAPPERS", "NEEDLE HOLDERS", 
                                                                          "NITROUS OXIDE PRODUCTS", "NON-ABSORBABLE SUTURE AND NEEDLE COMBINATION", 
                                                                          "NON-CONTROLLED MEDICATIONS", "OBTURATION SYSTEMS AND ACCESSORIES", 
                                                                          "OBTURATORS", "OCCLUSAL INDICATORS", "OFFICE SAFETY MISCELLANEOUS", 
                                                                          "OFFICE SUPPLIES", "OPERATORY LABORATORY BULBS", "ORAL APPLIANCES AND ACCESSORIES", 
                                                                          "ORAL CUP LINERS", "ORGANIZATION AND IDENTIFICATION MISC.", "ORTHODONTIC ATTACHMENTS", 
                                                                          "ORTHODONTIC BANDS - PLAIN", "ORTHODONTIC BANDS - PREWELDED", 
                                                                          "ORTHODONTIC BRACKETS", "ORTHODONTIC BUCCAL TUBES", "ORTHODONTIC ELASTOMERICS", 
                                                                          "ORTHODONTIC HEADGEAR", "ORTHODONTIC INSTRUMENTS", "ORTHODONTIC MISCELLANEOUS", 
                                                                          "ORTHODONTIC RESIN", "ORTHODONTIC WIRE", "OXIMETERS", "PACKING INSTRUMENTS", 
                                                                          "PAPER MISCELLANEOUS", "PASTE FILLERS", "PATIENT BIBS - POLY TOWELS", 
                                                                          "PATIENT COMFORT", "PATIENT GIVEAWAYS MISCELLANEOUS", "PERIODONTAL DRESSINGS", 
                                                                          "PIEZO SCALER TIPS", "PIN DRILLS", "PINS AND POSTS MISCELLANEOUS", 
                                                                          "PINS RESTORATIVE", "PIT AND FISSURE SEALANTS", "PLACEMENT INSTRUMENTS", 
                                                                          "PLASTER", "PLASTER TRAPS AND ACCESSORIES", "PLASTIC AND WAX SPRUES", 
                                                                          "POLISHERS", "PORCELAIN", "PORCELAIN BRUSHES", "PORCELAIN PALLETS AND SLABS", 
                                                                          "PORCELAIN STAINS", "POST DRILLS AND REAMERS", "POSTS LABORATORY", 
                                                                          "POSTS METAL ENDODONTIC", "POSTS METAL FREE", "PREPARATION AND FINISHING KITS", 
                                                                          "PRESSABLE CERAMICS", "PREVENTIVE MISCELLANEOUS", "PROBES AND POCKET MARKERS", 
                                                                          "PROPHY BRUSHES", "PROPHY CUPS", "PROPHY PASTE", "PROPHYLAXIS POWDER", 
                                                                          "RESTORATIVES MISCELLANEOUS", "RETAINER AND DENTURE BOXES", "RETRACTION CORD MEDICATED", 
                                                                          "RETRACTION CORD PLAIN", "RETRACTION LIQUIDS", "RETRACTION MISCELLANEOUS", 
                                                                          "RETRACTION PASTE", "RETRACTION PELLETS", "RETRACTORS - GINGIVAL, CHEEK AND TISSUE", 
                                                                          "RONGEURS", "ROOT TIP PICKS", "ROPE WAX", "RUBBER DAM CLAMPS", 
                                                                          "RUBBER DAM FORCEPS", "RUBBER DAM FRAMES", "RUBBER DAM MATERIAL LATEX", 
                                                                          "RUBBER DAM MATERIAL LATEX FREE", "RUBBER DAM MISCELLANEOUS", 
                                                                          "RUBBER DAM PUNCH", "RUBBER POINTS AND WHEELS", "SALES & EQUIP DEPT CREDITS", 
                                                                          "SALIVA EJECTOR ACCESSORIES", "SALIVA EJECTORS", "SANDBLASTERS AND ACCESSORIES", 
                                                                          "SAW FRAMES AND BLADES", "SCALERS AND CURETTES", "SCALPEL AND SUTURE MISCELLANEOUS", 
                                                                          "SCALPEL BLADES", "SCALPEL HANDLES", "SCALPELS", "SCISSORS - CROWN", 
                                                                          "SEPARATING DISCS", "SEPARATING LIQUID AND FOIL", "SHADE GUIDES", 
                                                                          "SHADE MATCHING LIGHTS", "SHARPENING PRODUCTS AND ACCESSORIES", 
                                                                          "SHARPS AND MEDICAL WASTE CONTAINERS", "SILANE CERAMIC AND ZIRCONIA REPAIR KITS", 
                                                                          "SILVER POINTS", "SMALL EQUIPMENT MISCELLANEOUS", "SOAP & LOTION DISPENSERS AND ACCESSORIES", 
                                                                          "SOAPS", "SOAPS AND LOTIONS MISC.", "SOLVENTS", "SPECIALTY TOOTHBRUSHES", 
                                                                          "SPILL KITS", "SPLASH PANS AND WORK PANS", "SPLINTS AND ACCESSORIES", 
                                                                          "SPONGE DISPENSERS", "SPONGES", "STERILANTS", "STERILIZING DISHES", 
                                                                          "STETHESCOPES", "STICKY WAX", "STUDENT KITS", "SURFACE DISINFECTANT SPRAYS", 
                                                                          "SURFACE DISINFECTANT WIPES", "SURGICAL BONE CHISELS AND FILES", 
                                                                          "SURGICAL CURETTES", "SURGICAL IMPLANT INSTRUMENTS", "SURGICAL IMPLANT INSTRUMENTS (USE 36052)", 
                                                                          "SURGICAL KNIVES", "SURGICAL MALLETS", "SURGICAL MISCELLANEOUS", 
                                                                          "SURGICAL SCISSORS", "SURGICAL/IMPLANT HANDPIECES", "SUTURE NEEDLES ONLY", 
                                                                          "SUTURES ONLY", "TABLE COVERS", "TEMPORARY FILLING MATERIAL", 
                                                                          "TEMPORARY MATERIAL CROWN AND BRIDGE", "TEMPORARY MATERIAL INLAY ONLAY", 
                                                                          "TEMPORARY PROVISIONAL MISCELLANEOUS", "TEST STRIPS GLUTERALDHYDE", 
                                                                          "TISSUE FORCEPS AND TISSUE PLIERS", "TONGUE CLEANERS", "TOOTHBRUSH SAVINGS PLANS", 
                                                                          "TOOTHBRUSHES", "TOOTHPASTE PRESCRIPTION AND SPECIALTY", "TOOTHPASTE REGULAR", 
                                                                          "TOWEL CLAMPS", "TOYS", "TRASH BAGS (REGULAR - NOT HAZARDOUS)", 
                                                                          "TRAY ADHESIVES", "TRAY CLEANERS", "TRAY MATERIAL", "TRAY RACKS", 
                                                                          "TRAYS CABINET TYPE", "TRAYS SET UP", "TRAYS, METAL", "TRAYS, PLASTIC", 
                                                                          "TUBS AND ACCESSORIES", "TURBINES FOR HANDPIECE", "ULTRASONIC CLEANER ACCESSORIES", 
                                                                          "ULTRASONIC CLEANER MISCELLANEOUS", "ULTRASONIC CLEANER SOLUTIONS", 
                                                                          "ULTRASONIC CLEANER TABLETS AND POWDERS", "ULTRASONIC CLEANERS", 
                                                                          "ULTRASONIC SCALER INSERTS", "ULTRASONIC SCALER TIPS", "ULTRASONIC SCALERS", 
                                                                          "UNIFORMS - WORKWEAR MISCELLANEOUS", "UNMOUNTED STONES", "UTILITY GLOVES", 
                                                                          "UTILITY WAX", "VACUUM FORMING BASE PLATE MATERIAL", "VACUUM FORMING CLEAR AND BLEACH TRAY MATERIAL", 
                                                                          "VACUUM FORMING COPING MATERIAL", "VACUUM FORMING MACHINES", 
                                                                          "VACUUM FORMING MATERIAL MISCELLANEOUS", "VACUUM FORMING MOUTHGUARD MATERIAL", 
                                                                          "VACUUM FORMING TEMPORARY SPLINT MATERIAL", "VACUUM FORMING TRAY MATERIAL", 
                                                                          "VIBRATORS", "WARNING LABELS AND SIGNAGE", "WATERLESS HAND CLEANERS", 
                                                                          "WATERLINE CLEANERS", "WAX AND PLASTIC PATTERNS AND MOLDS", "WAX BITE BLOCKS", 
                                                                          "WAX BITE WAFERS", "WAX MISCELLANEOUS", "WAX SHAPES", "WEDGES", 
                                                                          "WORKWEAR DISPOSABLE GOWNS", "WORKWEAR DISPOSABLE JACKETS AND PANTS", 
                                                                          "WORKWEAR NON DISPOSABLE SCRUBS AND PANTS", "WORKWEAR NON-DISPOSABLE JACKETS", 
                                                                          "WORKWEAR NON-DISPOSABLE LAB COATS", "X-RAY APRON HANGERS", "X-RAY APRONS", 
                                                                          "X-RAY CLEANER SOLUTIONS AND FILMS", "X-RAY DUPLICATORS", "X-RAY ENVELOPES", 
                                                                          "X-RAY FILM DUPLICATING", "X-RAY FILM EXTRAORAL", "X-RAY FILM INTRAORAL", 
                                                                          "X-RAY HANGERS", "X-RAY HOLDING DEVICES - DISPOSABLE", "X-RAY HOLDING DEVICES - REUSABLE", 
                                                                          "X-RAY MISC", "X-RAY MOUNTS PAPER", "X-RAY MOUNTS PLASTIC", "X-RAY SOLUTION AUTOMATIC", 
                                                                          "X-RAY SOLUTION MANUAL", "X-RAY VIEWERS"), class = "factor"), 
                      Total_PL_Sales = c(1234316L, 1169840L, 1269927L, 1099243L, 
                                         8630443L, 1394818L, 1009520L, 715253L, 3549380L, 1317697L, 
                                         8969263L, 2496937L, 1499510L, 5754224L, 4310017L, 717098L, 
                                         1787716L, 824143L, 877371L, 1195988L, 939660L, 596172L, 875923L, 
                                         826441L, 697105L, 855677L, 2227560L, 783534L, 5320961L, 770653L, 
                                         6056824L, 11724759L, 2296832L, 759721L, 2035162L, 3880362L, 
                                         1028932L, 1953396L, 4432424L, 2315870L, 4292177L, 2020471L, 
                                         1032038L, 7977116L, 2561065L, 696595L, 1222962L, 1052915L, 
                                         2415567L, 1677023L), Total_NonPL_Sales = c(3014933L, 5739664L, 
                                                                                    4162330L, 14002141L, 3370726L, 1973290L, 2147340L, 3803243L, 
                                                                                    19023793L, 593427L, 2752915L, 2812147L, 1851203L, 5960716L, 
                                                                                    4157671L, 3857395L, 12480624L, 1216983L, 6074633L, 2177528L, 
                                                                                    14489664L, 604659L, 364440L, 13296896L, 8243432L, 1098600L, 
                                                                                    3920394L, 1917838L, 13179946L, 3005790L, 7510677L, 24675499L, 
                                                                                    907733L, 3078727L, 30440956L, 6338198L, 1013193L, 1875104L, 
                                                                                    1423372L, 1418671L, 2807208L, 2147044L, 4505228L, 10479493L, 
                                                                                    161322L, 12550672L, 10566223L, 1730896L, 1864963L, 1001911L
                                         )), row.names = c(NA, -50L), class = c("tbl_df", "tbl", "data.frame"
                                         ))

df8e %>% 
  gather(Buckets, value, -ITEM_CATEGORY_DESCR) %>% 
  ggplot(aes(x = ITEM_CATEGORY_DESCR, y = value, fill = Buckets)) +
  geom_col() +
  theme(axis.text.x=element_text(angle = 60,vjust=.5),
        axis.text.y=element_text(size = 8, face = "bold"),
        legend.position = "top") +
  scale_y_continuous(labels=(dollar_format(prefix="$"))) +
  labs(x="", y="") +
  scale_fill_discrete(name = "Buckets",breaks=c("Total_NonPL_Sales","Total_PL_Sales"),
                      labels=c("Non-PL Sales","PL Sales"))+
  coord_flip()

(Image was censored)
Created on 2018-07-10 by the reprex
package
(v0.2.0).

Thank you!


#2

Here is a little example of reordering:

tibble(x = factor(sample(LETTERS,20)), y = sample(1:100,20)) %>% 
  ggplot(aes(x = reorder(x,-y), y = y)) +
  geom_col()

#3

That is a different way to reorder. I have used that but this is not what I want. Thanks!


#4

Is this then what you are looking for?

tibble(x = factor(sample(LETTERS,10)), y = sample(1:100,10)) %>% 
  arrange(desc(y))
# A tibble: 10 x 2
   x         y
   <fct> <int>
 1 A        99
 2 B        93
 3 Q        87
 4 Y        77
 5 Z        74
 6 S        71
 7 M        19
 8 H        17
 9 C        14
10 U         5

#5

Leon:
If you copy and paste the code above, the data frame is completely different from yours.

I plot two columns on my data frame against each other in a stacked bar.

Your data frame or plot basically does not plot 2 variables against each other.

If you want, like I said, copy and paste my code above and run it. Try to use reorder() and see it yourself.

Thanks.


#6

@Leon's point is still correct: reorder is the tool for the job. You just have to use it before the gather step.

 df8e %>% 
  mutate(ITEM_CATEGORY_DESCR = reorder(ITEM_CATEGORY_DESCR, Total_PL_Sales)) %>%
  gather(Buckets, value, -ITEM_CATEGORY_DESCR) %>%
  ggplot(aes(x = ITEM_CATEGORY_DESCR, y = value, fill = Buckets)) +
  geom_col() +
  coord_flip()

#7

Thanks! I appreciate your help.


#8

Great that you solved your challenge!

I would however for future reference recommend to downscale and simplify your examples. If the example is unnecessarily complicated, it takes focus from the technical challenge, for which you're seeking input - Hence my intentional use of small "dummy" tibbles. Also, appreciating the solution to the specific technical issue and then applying it to your particular challenge, imho increases the learning yield :slightly_smiling_face:


#9

Leon:
I used dput(data[1:5,]) and there are still tons of information coming out of that command.
I did not know what else I could do to limit down the sample size.