rlang/plain.r

608 lines
41 KiB
R
Raw Normal View History

2022-05-02 09:48:04 -04:00
library(plyr)
library(dplyr)
library(ggdistribute)
library(ggplot2)
library(ggExtra)
library(scales)
library(gridExtra)
library(stringr);
library(DBI);
mold = "BWS00200"
colgrp = "B"
branding = "^$"
xfact = 4
yfact = 5
xtrans = "identity"
ytrans = "identity"
sql = paste("WITH
colortier AS (
SELECT * FROM (VALUES
('B','BASE','0'),
('D','CUSTOM','5'),
('F','CUSTOM','6'),
('C','CUSTOM','7'),
('E','ECOGROW','2'),
('O','ORGANIC','3'),
('M','PREMIUM CORE (C)','3'),
('L','PRINCIPAL CORE (B)','2'),
('P','PROGRAM','4'),
('T','TRADITIONAL CORE (A)','1'),
('W','WAXTOUGH','1')
) x(cltier,cldesc,clsort)
)
,regional AS (
SELECT * FROM (VALUES
('CY GROWERS SUPPLIES','Canadian Distributors - July 2021','Can','CYGR0002','NDIS','CY GROWERS SUPPLIES LTD (U)','CY GROWERS SUPPLIES LTD','A','CAN','NUDU'),
('CY GROWERS SUPPLIES','Canadian Distributors - July 2021','Can','CYGR0003','NDIS','CY GROWERS SUPPLIES LTD U','CY GROWERS SUPPLIES LTD','A','CAN','NUDU'),
('TERIS SVSC D APPROVISIONNEMNT','Canadian Distributors - July 2021','Can','DIST0008','GDIS','TERIS SVSC D''APPROVISIONNEMNTU','TERIS SUPPLY SERVICES','A','CAN','NUDU'),
('CANADIAN HYDROGARDENS LTD','Canadian Distributors - July 2021','Can','CANA0013','GDIS','CANADIAN HYDROGARDENS LTD',CAST(NULL AS text),'A','CAN','NUDU'),
('GLOBAL HORTICULTURE INC','Canadian Distributors - July 2021','Can','GLOB0014','GDIS','GLOBAL HORTICULTURAL INC (U)','GLOBAL HORTICULTURAL INC','A','CAN','NUDU'),
('PROFESSIONAL GARDENER CO','Canadian Distributors - July 2021','Can','PROF0003','GDIS','PROFESSIONAL GARDENER CO (U)','PROFESSIONAL GARDENER CO','A','CAN','NUDU'),
('AMA PLASTICS','Canadian Distributors - July 2021','Can','AMAP0007','GDIS','AMA HORTICULTURE INC (U)','AMA PLASTICS','A','CAN','NUDU'),
('HALIFAX SEED CO','Canadian Distributors - July 2021','Can','HALI0004','GDIS','HALIFAX ST JOHN (U)','HALIFAX ST JOHN','A','CAN','NUDU'),
('HALIFAX SEED CO','Canadian Distributors - July 2021','Can','HALI0005','GDIS','HALIFAX SEED DIST CENTER (U)','HALIFAX SEED CO INC','A','CAN','NUDU'),
('HALIFAX SEED CO','Canadian Distributors - July 2021','Can','HALI0011','GDIS','HALIFAX SEED CO INC (U)','HALIFAX SEED CO INC','A','CAN','NUDU'),
('HJS WHOLESALE LTD','Canadian Distributors - July 2021','Can','HJSW0001','GDIS','HJS WHOLESALE LTD (C)','HJS WHOLESALE LTD','A','CAN','NUDU'),
('HJS WHOLESALE LTD','Canadian Distributors - July 2021','Can','HJSW0002','GDIS','HJS WHOLESALE LTD (U)','HJS WHOLESALE LTD','A','CAN','NUDU'),
('HJS WHOLESALE LTD','Canadian Distributors - July 2021','Can','HJSW0003','GDRP','HJS WHOLESALE LTD (U)','HJS WHOLESALE LTD','A','CAN','NUDU'),
('BIOFLORAL INC','Canadian Distributors - July 2021','Can','BIOF0003','NDIS','BIOFLORAL INC (U)','BIOFLORAL INC','A','CAN','NUDU'),
('BRADFORD CO-OP STORAGE LTD','Canadian Distributors - July 2021','Can','BRAD0006','GDIS','BRADFORD CO-OP STORAGE LTD','BRADFORD CO-OP STORAGE LTD','A','CAN','NUDU'),
('BRADFORD CO-OP STORAGE LTD','Canadian Distributors - July 2021','Can','BRAD0020','GDIS','BRADFORD CO-OP STORAGE LTD (U)','BRADFORD CO-OP STORAGE LTD','A','CAN','NUDU'),
('MARTIN''S PRODUCE','East and MidAtlantic States - July 2021','East','MART0020','GDIS','MARTINS PRODUCE',CAST(NULL AS text),'A','USA','NUEU'),
('KC SCHAEFER SUPPLY','East and MidAtlantic States - July 2021','East','KCSC0001','GDIS','KC SCHAEFER SUPPLY CO INC','KC SCHAEFER SUPPLY','A','USA','NUEU'),
('GARDEN DOMINION','East and MidAtlantic States - July 2021','East','GARD0154','NDIS','GARDEN DOMINION LLC',CAST(NULL AS text),'A','USA','NUEU'),
('HYDROTEK HYDROPONICS','East and MidAtlantic States - July 2021','East','HYDR0028','NDIS','HYDROTEK USA - CHAMPLAIN','HYDROTEK HYDROPONICS','A','USA','NUEU'),
('HYDROTEK HYDROPONICS','East and MidAtlantic States - July 2021','East','HYDR0029','NDIS','HYDROTEK','HYDROTEK HYDROPONICS','A','CAN','NUDU'),
('PASTANCH','East and MidAtlantic States - July 2021','East','PAST0002','NDIS','PASTANCH LLC','PASTANCH LLC','A','USA','NUEU'),
('GREEN ISLAND','East and MidAtlantic States - July 2021','East','GREE0005','GDIS','GREEN ISLAND DISTRIBUTORS INC.',CAST(NULL AS text),'A','USA','NUEU'),
('VAS AGRICULTURAL SUPPLY','Florida and Gulf States - July 2021','Gulf','VASA0002','NDIS','VAS AGRICULTURAL SUPPLY','VAS AGRICULTURAL SUPPLY','A','USA','NUFU'),
('VAS AGRICULTURAL SUPPLY','Florida and Gulf States - July 2021','Gulf','VASA0003','NDIS','VAS AGRICULTURAL SUPPLY','VAS AGRICULTURAL SUPPLY','A','USA','NUFU'),
('GRC AGROINDUSTRIAL','Florida and Gulf States - July 2021','Gulf','GRCA0001','GDIS','GRC AGROINDUSTRIAL','GRC AGROINDUSTRIAL','A','USA','NUFU'),
('GRC AGROINDUSTRIAL','Florida and Gulf States - July 2021','Gulf','GRCA0005','GDIS','GRC AGROINDUSTRIAL','GRC AGROINDUSTRIAL','A','USA','NUFU'),
('WINFIELD SOLUTIONS - FLORIDA','Florida and Gulf States - July 2021','Gulf','PROS000A','GDIS','WINFIELD SOLUTIONS - WAUCHULA',CAST(NULL AS text),'A','USA','NUFU'),
('WINFIELD SOLUTIONS - FLORIDA','Florida and Gulf States - July 2021','Gulf','PROS000B','GDIS','WINFIELD SOLUTIONS BOYNTON BCH','PRO SOURCE','A','USA','NUFU'),
('WINFIELD SOLUTIONS - FLORIDA','Florida and Gulf States - July 2021','Gulf','PROS000E','GDIS','WINFIELD SOLUTIONS - ELLENTON',CAST(NULL AS text),'A','USA','NUFU'),
('WINFIELD SOLUTIONS - FLORIDA','Florida and Gulf States - July 2021','Gulf','PROS000I','GDIS','WINFIELD SOLUTIONS - IMMOKALEE','PRO SOURCE','A','USA','NUFU'),
('WINFIELD SOLUTIONS - FLORIDA','Florida and Gulf States - July 2021','Gulf','PROS000P','GDIS','WINFIELD SOLUTIONS -PLANT CITY','PRO SOURCE','A','USA','NUFU'),
('WINFIELD SOLUTIONS - FLORIDA','Florida and Gulf States - July 2021','Gulf','PROS000Y','GDIS','WINFIELD SOLUTIONS - APOPKA','PRO SOURCE','A','USA','NUFU'),
('DIAMOND R','Florida and Gulf States - July 2021','Gulf','DIAM0004','NDIS','DIAMOND R FERTILIZER CO INC','DIAMOND R','A','USA','NUFU'),
('DIAMOND R','Florida and Gulf States - July 2021','Gulf','DIAM0005','NDIS','DIAMOND R - PLANT CITY','DIAMOND R','A','USA','NUFU'),
('DIAMOND R','Florida and Gulf States - July 2021','Gulf','DIAM0006','NDIS','DIAMOND R - LABELLE','DIAMOND R','A','USA','NUFU'),
('DIAMOND R','Florida and Gulf States - July 2021','Gulf','DIAM0007','NDIS','DIAMOND R FERTILIZER-WINTERGDN','DIAMOND R','A','USA','NUFU'),
('DIAMOND R','Florida and Gulf States - July 2021','Gulf','DIAM0008','NDIS','DIAMOND R-HOMESTEAD','DIAMOND R','A','USA','NUFU'),
('DIAMOND R','Florida and Gulf States - July 2021','Gulf','DIAM0009','GDIS','DIAMOND R FERTILIZER-EP','DIAMOND R','A','USA','NUFU'),
('DIAMOND R','Florida and Gulf States - July 2021','Gulf','DIAM0010','GDIS','DIAMOND R FERT - OKEECHOBEE','DIAMOND R','A','USA','NUFU'),
('B&T GROWERS SUPPLY','Florida and Gulf States - July 2021','Gulf','BTGR0001','GDIS','B&T GROWERS SUPPLY','B&T GROWERS SUPPLY','A','USA','NUFU'),
('CARLIN HORTICULTURAL SUPPLIES','MidWest States Nursery Distributors - July 2021','MidW','CARL0002','GDIS','CARLIN HORTICULTURAL SUPP U','CARLIN HORTICULTURAL SUPP','A','USA','NUGU'),
('CARLIN HORTICULTURAL SUPPLIES','MidWest States Nursery Distributors - July 2021','MidW','CARL0015','GDIS','CARLIN HORTICULTURAL SUPP','CARLIN HORTICULTURAL SUPP','A','USA','NUGU'),
('PREMIUM HORTICULTURAL SUPPLIES','MidWest States Nursery Distributors - July 2021','MidW','PREM0003','GDIS','PREMIUM HORTICULTURAL SUPPLY','PREMIUM HORTICULTURAL SUPPLY','A','USA','NUGU'),
('PREMIUM HORTICULTURAL SUPPLIES','MidWest States Nursery Distributors - July 2021','MidW','PREM0013','GDIS','PREMIUM HORTICULTURAL SUPPLY','PREMIUM HORTICULTURAL SUPPLY','A','USA','NUGU'),
('VANDENBERG BULB CO','MidWest States Nursery Distributors - July 2021','MidW','VAND0001','GDIS','VANDENBERG BULB CO INC',CAST(NULL AS text),'A','USA','NUGU'),
('FARMERS COOP','MidWest States Nursery Distributors - July 2021','MidW','FARM0001','GDIS','FARMERS COOPERATIVE ELEVATOR','FARMERS COOP','A','USA','NUGU'),
('FARMERS COOP','MidWest States Nursery Distributors - July 2021','MidW','FARM0029','RDIR','FARMERS CO-OP ASSOCIATION INC','FARMERS COOP','A','USA','NUGU'),
('FARMERS COOP','MidWest States Nursery Distributors - July 2021','MidW','FARM0041','RDIR','FARMERS COOPLINCOLN','FARMERS COOP','A','USA','NUGU'),
('FARMERS COOP','MidWest States Nursery Distributors - July 2021','MidW','FARM0042','GDIS','FARMERS COOPVAN BUREN','FARMERS COOP','A','USA','NUGU'),
('FARMERS COOP','MidWest States Nursery Distributors - July 2021','MidW','FARM0047','GDRP','FARMERS CO-OP ASSOC. STANTON','FARMERS COOP','A','USA','NUGU'),
('FARMERS COOP','MidWest States Nursery Distributors - July 2021','MidW','TRUE0060','RMAS','FARMERS COOPERATIVE','FARMERS COOP','A','USA','NUGU'),
('TESSMAN SEED','MidWest States Nursery Distributors - July 2021','MidW','TESS0001','GDIS','TESSMAN SEED','TESSMAN SEED','A','USA','NUGU'),
('TESSMAN SEED','MidWest States Nursery Distributors - July 2021','MidW','TESS0002','GDIS','TESSMAN SEED','TESSMAN SEED','A','USA','NUGU'),
('TESSMAN SEED','MidWest States Nursery Distributors - July 2021','MidW','TESS0003','GDIS','TESSMAN COMPANY','TESSMAN SEED','A','USA','NUGU'),
('YODERS PRODUCE','MidWest States Nursery Distributors - July 2021','MidW','YODE0010','GDIS','YODERS PRODUCE INC','YODERS PRODUCE','A','USA','NUGU'),
('YODERS PRODUCE','MidWest States Nursery Distributors - July 2021','MidW','YODE0015','GDRP','YODERS PRODUCE','YODERS PRODUCE','A','USA','NUGU'),
('HORTMARK','MidWest States Nursery Distributors - July 2021','MidW','HORT0004','GDIS','HORTMARK',CAST(NULL AS text),'A','USA','NUGU'),
('WALDO & ASSOCIATES','MidWest States Nursery Distributors - July 2021','MidW','WALD0003','GDIS','WALDO & ASSOCIATES',CAST(NULL AS text),'A','USA','NUGU'),
('PRO GROWERS','Pacific Northwest and Rocky Mountain States - July 2021','PacNW','PROG0010','GDIS','PRO GROWER SUPPLY','PRO GROWER SUPPLY','A','USA','NUWU'),
('PRO GROWERS','Pacific Northwest and Rocky Mountain States - July 2021','PacNW','PROG0012','GDIS','PRO GROWER SUPPLY','PRO GROWER SUPPLY','A','USA','NUWU'),
('PRO GROWERS','Pacific Northwest and Rocky Mountain States - July 2021','PacNW','PROG0016','GDRP','PRO GROWER SUPPLY','PRO GROWER SUPPLY','A','USA','NUWU'),
('OBC NORTHWEST','Pacific Northwest and Rocky Mountain States - July 2021','PacNW','OBCN0001','GDIS','OBC NORTHWEST INC','OBC NORTHWEST INC','A','USA','NUWU'),
('OBC NORTHWEST','Pacific Northwest and Rocky Mountain States - July 2021','PacNW','OBCN0002','GDIS','OBC NORTHWEST INC','OBC NORTHWEST INC','A','USA','NUWU'),
('JR SIMPLOT','Pacific Northwest and Rocky Mountain States - July 2021','PacNW','JRSI0001','NDIS','JR SIMPLOT COMPANY','JR SIMPLOT','A','USA','NUWU'),
('JR SIMPLOT','Pacific Northwest and Rocky Mountain States - July 2021','PacNW','JRSI0002','NDIS','JR SIMPLOT COMPANY','JR SIMPLOT','A','USA','NUWU'),
('JR SIMPLOT','Pacific Northwest and Rocky Mountain States - July 2021','PacNW','JRSI0003','NDIS','JR SIMPLOT','JR SIMPLOT','A','USA','NUWU'),
('JR SIMPLOT','Pacific Northwest and Rocky Mountain States - July 2021','PacNW','JRSI0004','NDIS','JR SIMPLOT - FULLERTON','JR SIMPLOT','A','USA','NUWU'),
('GROWERS NURSERY SUPPLY','Pacific Northwest and Rocky Mountain States - July 2021','PacNW','GROW0016','GDIS','GROWERS NURSERY SUPPLY INC','GROWERS NURSERY SUPPLY INC','A','USA','NUWU'),
('KINNEY BONDED','Southern States - July 2021','South','KINN0002','GDIS','KINNEY BONDED WAREHOUSE INC','KINNEY BONDED','A','USA','NUSU'),
('KINNEY BONDED','Southern States - July 2021','South','KINN0003','GDIS','KINNEY BONDED TYLER','KINNEY BONDED','A','USA','NUSU'),
('GREENHOUSE MEGASTORE','Southern States - July 2021','South','INTE0003','GDIS','GREENHOUSE MEGASTORE','GREENHOUSE MEGASTORE','A','USA','NUSU'),
('GREENHOUSE MEGASTORE','Southern States - July 2021','South','INTE0010','GDIS','GREENHOUSE MEGASTORE - CA','GREENHOUSE MEGASTORE','A','USA','NUSU'),
('HORTICULTURAL DISTRIBUTORS INC','Southern States - July 2021','South','HORT0002','GDIS','HORTICULTURAL DISTRIBUTORS INC',CAST(NULL AS text),'A','USA','NUSU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','CROP0006','GDRP','NUTRIEN AG SOLUTIONS- CHANDLER','CROP PROD SERVICES INC','A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','CROP0007','GDIS','NUTRIEN AG SOLUTION-SANTAMARIA','CROP PROD SERVICES INC','A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','CROP0008','GDIS','NUTRIEN AG SOLUTION-SACRAMENTO','CROP PROD SERVICES INC','A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','CROP0009','GDRP','NUTRIEN AG SOLUTIONS INC-KUNIA','CROP PROD SERVICES INC','A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','CROP0010','GDIS','NUTRIEN AG SOLUTIONS INC-LIHUE',CAST(NULL AS text),'A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','CROP0011','GDIS','NUTRIEN AG SOL.- OXNARD-DUFAU','CROP PROD SERVICES INC','A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','CROP0012','GDRP','NUTRIEN AG SOLUTION-BURLINGTON',CAST(NULL AS text),'A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','CROP0013','GDIS','NUTRIEN AG SOLUTIONS - NEWLAND',CAST(NULL AS text),'A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','CROP0014','GDIS','NUTRIEN AG SOLUTIONS CDN INC C','CROP PROD SERVICES INC','A','CAN','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','CROP0015','GDRP','NUTRIEN AG SOLUTIONS -ANAHEIM',CAST(NULL AS text),'A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','CROP0016','GDRP','NUTRIEN AG SOLUTIONS - TUCSON','CROP PROD SERVICES INC','A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','CROP0017','GDIS','NUTRIEN AG SOL. - SAN JACINTO','CROP PROD SERVICES INC','A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','CROP0018','GDIS','NUTRIEN AG SOLUTIONS INC','CROP PROD SERVICES INC','A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','CROP0020','GDIS','NUTRIEN AG SOLUTIONS CDN INC U','CROP PROD SERVICES INC','A','CAN','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','NUGR0001','GDIS','NUTRIEN AG SOLUTIONS CDN INC C','CROP PROD SERVICES INC','A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','NUGR0002','GDIS','NUTRIEN AG SOLUTIONS CDN INC U','CROP PROD SERVICES INC','A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','NUTR0001','GDIS','NUTRIEN HAWAIINVD SAC INV7520','CROP PROD SERVICES INC','A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','NUTR0002','GDIS','NUTRIEN AG SOLUTIONS CANADA U','NUTRIEN AG SOLUTIONS CANADA','A','CAN','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','NUTR0003','GDRP','NUTRIEN AG SOLUTIONS-OXNARD','NUTRIEN AG SOLUTIONS-OXNARD','A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','SUNC0011','GDRP','NUTRIEN AG SOLUTION-MEADOWLAND','CROP PROD SERVICES INC','A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','UAPD0005','GDRP','NUTRIEN AG SOLUTIONS INC',CAST(NULL AS text),'A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','VERD0006','GDIS','NUTRIEN AG SOLUTIONS - FRESNO','CROP PROD SERVICES INC','A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','VERD0007','GDRP','NUTRIEN AG SOLUTIONS INC - HI',CAST(NULL AS text),'A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','WEST0006','GDIS','NUTRIEN AG SOLUTIONS (CPS)','CROP PROD SERVICES INC','A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','WEST0602','GDIS','NUTRIEN AG SOLUTIONS-RIVERSIDE','CROP PROD SERVICES INC','A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','WEST0603','GDIS','NUTRIEN AG SOLUTIONS -FILLMORE',CAST(NULL AS text),'A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','WEST0605','GDIS','NUTRIEN AG SOLUTION-SAN MARCOS','NUTRIEN','A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','WEST0646','GDIS','NUTRIEN AG SOL. - WATSONVILLE','CROP PROD SERVICES INC','A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','WEST0657','GDIS','NUTRIEN AG SOLUTIONS - GOLETA','CROP PROD SERVICES INC','A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','WEST0660','GDIS','NUTRIEN AG SOLUTIONS - OXNARD','CROP PROD SERVICES INC','A','USA','NUWU'),
('NUTRIEN','West Coast Nursery and National Cannabis Distributors - July 2021','West','WEST0665','GDIS','NUTRIEN AG SOLUTIONS - GRESHAM',CAST(NULL AS text),'A','USA','NUWU'),
('RS GROWERS SUPPLY','West Coast Nursery and National Cannabis Distributors - July 2021','West','RSGR0001','GDIS','RS GROWERS SUPPLY INC','RS GROWERS SUPPLY','A','USA','NUWU'),
('RS GROWERS SUPPLY','West Coast Nursery and National Cannabis Distributors - July 2021','West','RSGR0004','GDIS','RS GROWERS SUPPLY INC','RS GROWERS SUPPLY','A','USA','NUWU'),
('HAWTHORNE','West Coast Nursery and National Cannabis Distributors - July 2021','West','HAWT0002','NDRP','HAWTHORNE HYDROPONICS','HAWTHORNE HYDROPONICS','A','USA','NUNU'),
('HAWTHORNE','West Coast Nursery and National Cannabis Distributors - July 2021','West','HAWT0010','NDIS','HAWTHORNE HYDROPONICS LLC',CAST(NULL AS text),'A','USA','NUNU'),
('HAWTHORNE','West Coast Nursery and National Cannabis Distributors - July 2021','West','HAWT0011','NDIS','HAWTHORNE HYDROPONICS LLC',CAST(NULL AS text),'A','USA','NUNU'),
('DL WHOLESALE','West Coast Nursery and National Cannabis Distributors - July 2021','West','DLWH0001','NDIS','DL WHOLESALE','DL WHOLESALE','A','USA','NUNU'),
('DL WHOLESALE','West Coast Nursery and National Cannabis Distributors - July 2021','West','DLWH0002','NDIS','DL WHOLESALE','DL WHOLESALE','A','USA','NUNU'),
('DL WHOLESALE','West Coast Nursery and National Cannabis Distributors - July 2021','West','DLWH0003','NDRP','DL WHOLESALE','DL WHOLESALE','A','USA','NUNU'),
('HYDROFARM','West Coast Nursery and National Cannabis Distributors - July 2021','West','HYDR0010','NDIS','HYDROFARM INC - PETALUMA CA','HYDROFARM','A','USA','NUNU'),
('HYDROFARM','West Coast Nursery and National Cannabis Distributors - July 2021','West','HYDR0012','NDIS','HYDROFARM - PENNSYLVANIA','HYDROFARM','A','USA','NUNU'),
('HYDROFARM','West Coast Nursery and National Cannabis Distributors - July 2021','West','HYDR0013','NDIS','HYDROFARM - COLORADO','HYDROFARM','A','USA','NUNU'),
('HYDROFARM','West Coast Nursery and National Cannabis Distributors - July 2021','West','HYDR0016','NDIS','HYDROFARM - SANTA FE SPRING CA','HYDROFARM','A','USA','NUNU'),
('HYDROFARM','West Coast Nursery and National Cannabis Distributors - July 2021','West','HYDR0017','NDIS','HYDROFARM - TEXAS','HYDROFARM','A','USA','NUNU'),
('HYDROFARM','West Coast Nursery and National Cannabis Distributors - July 2021','West','HYDR0021','NDIS','HYDROFARM - DENVER','HYDROFARM','A','USA','NUNU'),
('HYDROFARM','West Coast Nursery and National Cannabis Distributors - July 2021','West','HYDR0027','GDIS','HYDROFARM - MICHIGAN','HYDROFARM','A','USA','NUNU'),
('HYDROFARM','West Coast Nursery and National Cannabis Distributors - July 2021','West','HYDR0030','NDIS','HYDROFARM - OREGON','HYDROFARM','A','USA','NUNU'),
('HYDROFARM','West Coast Nursery and National Cannabis Distributors - July 2021','West','HYDR0032','NDRP','HYDROFARM - FONTANA','HYDROFARM - FONTANA','A','USA','NUNU'),
('GRIFFIN CEA','West Coast Nursery and National Cannabis Distributors - July 2021','West','GRIF0001','GDIS','GRIFFIN GREENHOUSE - TEWKSBURY','GRIFFIN','A','USA','NUNU'),
('GRIFFIN CEA','West Coast Nursery and National Cannabis Distributors - July 2021','West','GRIF0002','GDIS','GRIFFIN GREENHOUSE - SCHENECTA','GRIFFIN','A','USA','NUNU'),
('GRIFFIN CEA','West Coast Nursery and National Cannabis Distributors - July 2021','West','GRIF0003','GDIS','GRIFFIN GREENHOUSE - GRAY','GRIFFIN','A','USA','NUNU'),
('GRIFFIN CEA','West Coast Nursery and National Cannabis Distributors - July 2021','West','GRIF0004','GDIS','GRIFFIN GREENHOUSE - CHESHIRE','GRIFFIN','A','USA','NUNU'),
('GRIFFIN CEA','West Coast Nursery and National Cannabis Distributors - July 2021','West','GRIF0005','GDIS','GRIFFIN GREENHOUSE - AUBURN','GRIFFIN','A','USA','NUNU'),
('GRIFFIN CEA','West Coast Nursery and National Cannabis Distributors - July 2021','West','GRIF0006','GDIS','GRIFFIN GREENHOUSE - EWING','GRIFFIN','A','USA','NUNU'),
('GRIFFIN CEA','West Coast Nursery and National Cannabis Distributors - July 2021','West','GRIF0007','GDIS','GRIFFIN GREENHOUSE - RICHMOND','GRIFFIN','A','USA','NUNU'),
('GRIFFIN CEA','West Coast Nursery and National Cannabis Distributors - July 2021','West','GRIF0009','GDIS','GRIFFIN GREENHOUSE - BROOKHAVE','GRIFFIN','A','USA','NUNU'),
('GRIFFIN CEA','West Coast Nursery and National Cannabis Distributors - July 2021','West','GRIF0010','GDIS','GRIFFIN GREENHOUSE - STAFFORD','GRIFFIN','A','USA','NUNU'),
('GRIFFIN CEA','West Coast Nursery and National Cannabis Distributors - July 2021','West','GRIF0011','GDIS','GRIFFIN GREENHOUSE - BRIDGETON','GRIFFIN','A','USA','NUNU'),
('GRIFFIN CEA','West Coast Nursery and National Cannabis Distributors - July 2021','West','GRIF0014','GDIS','GRIFFIN GREENHOUSE - MORGANTWN','GRIFFIN','A','USA','NUNU'),
('GRIFFIN CEA','West Coast Nursery and National Cannabis Distributors - July 2021','West','GRIF0015','GDIS','GRIFFIN GREENHOUSE -WHSE 15','GRIFFIN','A','USA','NUNU'),
('GRIFFIN CEA','West Coast Nursery and National Cannabis Distributors - July 2021','West','GRIF0018','GDIS','GRIFFIN GREENHOUSE-BALL GROUND','GRIFFIN','A','USA','NUNU'),
('GRIFFIN CEA','West Coast Nursery and National Cannabis Distributors - July 2021','West','GRIF0019','GDIS','GRIFFIN GREENHOUSE-AURORA','GRIFFIN','A','USA','NUNU'),
('GRIFFIN CEA','West Coast Nursery and National Cannabis Distributors - July 2021','West','GRIF0020','GDIS','GRIFFIN GREENHOUSE - TEWKSBURY','GRIFFIN','A','USA','NUNU'),
('GRIFFIN CEA','West Coast Nursery and National Cannabis Distributors - July 2021','West','GRIF0021','GDIS','GRIFFIN GREENHOUSE - SALEM,OR','GRIFFIN','A','USA','NUNU'),
('GRIFFIN CEA','West Coast Nursery and National Cannabis Distributors - July 2021','West','GRIF0024','GDIS','GRIFFIN GREENHOUSE - SALEM CEA','GRIFFIN GREENHOUSE - SALEM CEA','A','USA','NUNU'),
('GRIFFIN CEA','West Coast Nursery and National Cannabis Distributors - July 2021','West','GRIF0036','GDIS','GRIFFIN GREENHOUSE - KNOXVILLE','GRIFFIN','A','USA','NUNU'),
('TERRA INTERNATIONAL','West Coast Nursery and National Cannabis Distributors - July 2021','West','TERR0019','NDIS','TERRA INTERNATIONAL','TERRA INTERNATIONAL','A','USA','NUNU'),
('TERRA INTERNATIONAL','West Coast Nursery and National Cannabis Distributors - July 2021','West','TERR0020','NDRP','TERRA INTERNATIONAL',CAST(NULL AS text),'A','USA','NUNU'),
('TERRA INTERNATIONAL','West Coast Nursery and National Cannabis Distributors - July 2021','West','TERR0023','GDRP','TERRA INTERNATIONALHYDRO CITY',CAST(NULL AS text),'A','USA','NUNU'),
('TERRA INTERNATIONAL','West Coast Nursery and National Cannabis Distributors - July 2021','West','TERR0025','GDIS','TERRA INTERNATIONAL','TERRA INTERNATIONAL','A','USA','NUNU'),
('TERRA INTERNATIONAL','West Coast Nursery and National Cannabis Distributors - July 2021','West','TERR0030','NDIS','TERRA INTERNATIONAL (SAC)','TERRA INTERNATIONAL (SAC)','A','USA','NUNU'),
('AMERICAN HORTICULTURAL SUPPLY','West Coast Nursery and National Cannabis Distributors - July 2021','West','AMER0004','GDIS','AMERICAN HORTICULTURAL SUPPLY','AMERICAN HORTICULTURAL SUPPLY','A','USA','NUWU'),
('AMERICAN HORTICULTURAL SUPPLY','West Coast Nursery and National Cannabis Distributors - July 2021','West','AMER0043','GDIS','AMERICAN HORTICULTURAL-','AMERICAN HORTICULTURAL SUPPLY','A','USA','NUWU'),
('PACIFIC NURSERY POTS','West Coast Nursery and National Cannabis Distributors - July 2021','West','PACI0025','NDIS','PACIFIC NURSERY POTS',CAST(NULL AS text),'A','USA','NUWU'),
('WINFIELD NATIONAL - Cannabis','West Coast Nursery and National Cannabis Distributors - July 2021','West','WINF0001','GDIS','WINFIELD SOLUTIONS LLC',CAST(NULL AS text),'A','USA','NUFU'),
('WINFIELD NATIONAL - Cannabis','West Coast Nursery and National Cannabis Distributors - July 2021','West','WINF0003','GDIS','WINFIELD SOLUTIONS - COLORADO','WINFIELD SOLUTIONS','A','USA','NUFU')
) x(customer,file,region,code,class,descr,dba,status,country,plist)
)
,xch AS (
SELECT * FROM ( VALUES
('DIRECT','DIR','Direct'),
('DISTRIB DROP SHIP','DRP','Drop'),
('DISTRIBUTOR','WHS','Warehouse')
) x(XCHAN, CHAN, TCHAN)
)
,ds AS (
SELECT * FROM ( VALUES
('B','X','BASE','Base',''),
('B','L','BASE LABELED','Base','L'),
('B','P','BASE PRINTED','Base','P'),
('C','X','COLOR','Color',''),
('C','L','COLOR LABELED','Color','L'),
('C','P','COLOR PRINTED','Color','P')
) x(colgrp, brand, dataseg, tcol, tbrand)
)
,pc AS MATERIALIZED (
SELECT
jcplcd
,jcpart
,jcunit
,min(jcpric) jcpric
FROM
lgdat.iprcc
WHERE
jcplcd ~ '^[GNF][CU]..$'
GROUP BY
jcplcd
,jcpart
,jcunit
)
SELECT
CASE o.chan WHEN 'DRP' THEN o.shipgrp ELSE o.account END customer,
--o.geo,
o.chan,
CASE WHEN substring(o.bill_class,1,1) = 'R' THEN 'X' ELSE substring(o.chan,1,1) END chgrp,
substring(o.part,1,8) mold,
o.sizc,
o.brnd,
COALESCE(i.accs_ps,'') kit,
i.suffix,
i.uomp package,
i.coltier,
o.colgrp,
o.dsm,
o.oseas,
prm.grp promo,
SUM(o.fb_qty) qty ,
SUM(o.fb_val_loc*o.r_rate) sales,
CASE
WHEN SUM(o.fb_qty) = 0 THEN 0
ELSE SUM(o.fb_val_loc*o.r_rate)/ SUM(o.fb_qty)
END price,
--x.xchan,
ds.dataseg,
t.target_price,
r.plist,
jcpric/1000 listprice,
greatest(jcpric/1000,CASE
WHEN SUM(o.fb_qty) = 0 THEN 0
ELSE SUM(o.fb_val_loc*o.r_rate)/ SUM(o.fb_qty)
END) maxprice,
COALESCE(r.region,o.geo) region
--,CASE WHEN o.geo = 'US WEST' THEN 'us west' ELSE 'elsewhere' END terr
--,CASE WHEN dsm in (select qr from rlarp.qrh where dir = 'Pierre' and qr <> '13026') THEN 'ME' ELSE 'OTH' END terr
FROM
rlarp.osm o
LEFT OUTER JOIN colortier ct ON
ct.cltier = o.coltier
----swap out channel names-----
LEFT OUTER JOIN xch x ON
x.chan = o.chan
----build data segments--------
LEFT OUTER JOIN ds ds ON
ds.colgrp = o.colgrp
AND ds.brand = substring(sizc,3,1)
LEFT OUTER JOIN pricequote.market_setavgprice t ON
t.chan = x.xchan
AND t.mold = substring(o.part,1,8)
AND t.data_segment = ds.dataseg
AND t.season = 2021
LEFT OUTER JOIN rlarp.prm ON
prm.promo = o.promo
LEFT OUTER JOIN rlarp.priceg pg ON
pg.part_group = substring(o.part,1,8)
LEFT OUTER JOIN \"CMS.CUSLG\".itemm i ON
i.item = o.part
LEFT OUTER JOIN rlarp.qrh ON
qrh.qr = o.dsm
INNER JOIN regional r ON
r.code = o.bill_cust
LEFT OUTER JOIN pc ON
pc.jcpart = o.part
AND pc.jcplcd = r.plist
WHERE
o.part ~ '",mold,"'
AND o.colgrp ~ '",colgrp,"'
AND o.brnd ~ '",branding,"'
AND o.oseas >= 2020
AND o.fs_line = '41010'
AND o.calc_status <> 'CANCELED'
AND o.version = 'ACTUALS'
AND o.odate <= '2021-01-22'
AND o.chan = 'WHS'
--AND i.aplnt <> 'I'
--AND o.ming <> 'B52'
--AND dsm in (select qr from rlarp.qrh where dir = 'Pierre' and qr <> '13026')
GROUP BY
CASE o.chan WHEN 'DRP' THEN o.shipgrp ELSE o.account END,
--o.geo,
o.chan,
CASE WHEN substring(o.bill_class,1,1) = 'R' THEN 'X' ELSE substring(o.chan,1,1) END,
substring(o.part,1,8),
o.sizc,
o.brnd,
COALESCE(i.accs_ps,''),
i.suffix,
i.uomp,
i.coltier,
o.colgrp,
o.dsm,
o.oseas,
prm.grp,
--x.xchan,
ds.dataseg,
t.target_price,
r.plist,
jcpric,
COALESCE(r.region,o.geo)
--,CASE WHEN o.geo = 'US WEST' then 'us west' ELSE 'elsewhere' END
--,CASE WHEN dsm in (select qr from rlarp.qrh where dir = 'Pierre' and qr <> '13026') THEN 'ME' ELSE 'OTH' END
HAVING
SUM(fb_qty) > 0
AND SUM(fb_val_loc*r_rate) > 0
AND CASE
WHEN SUM(o.fb_qty) = 0 THEN 0
ELSE SUM(o.fb_val_loc*o.r_rate)/ SUM(o.fb_qty)
END BETWEEN .01 AND 100
",sep="");
con <- dbConnect(RPostgres::Postgres(),dbname = 'ubm',
host = 'usmidlnx01.gbl.hc-companies.com',
port = 5030,
user = 'report',
password = 'report')
d <- dbGetQuery(con, sql)
#d;
dbDisconnect(con)
#-----each graph is composed of 2 pieces when doing the facet() pivot, these 2 pieces make up the plot defition-----
#d$dim1 <- trimws(paste(d$mold,d$colgrp,d$brnd,$region));
d$dim1 <- trimws(paste(d$mold,d$colgrp,d$brnd,d$plist));
d$dim2 <- trimws(paste(d$chgrp,d$suffix));
d$plot <- trimws(paste(d$dim1,d$dim2));
#d$sub <- trimws(paste(d$coltier,d$kit,d$suffix,d$package));
d$sub <- trimws(paste(d$oseas));
#d$sub <- trimws(paste(d$geo));
d$qty = d$qty/1000;
d$volmin = .0001;
d$season = factor(d$oseas);
#-----build widths for how many scenarios are present----------------------------------------------------------------
dim1 <- data.frame(unique(d$dim1));
var.dim1 = nrow(dim1);
dim2 <- data.frame(unique(d$dim2));
var.dim2 = nrow(dim2);
#-----------need to do an aggregate to consolidate to single customer point
d <- subset(d,chgrp != "X", promo != "Excess and Obsolete");
#-------------------------eliminate outliers-------------------------------------------------------------------------
dx <- boxplot.stats(d$price, coef = 6);
ex <- data.frame(dx$out);
#ex; #list the excluded outlier prices
colnames(ex)[1] = "price";
outl <- inner_join(d,ex, by = "price");
#outl;
#d <- anti_join(d,ex, by = "price");
#---------switch to log axis if there are still outliers with a coefficient 3----------------------------------------
var.trans = "identity"
if (nrow(data.frame(boxplot.stats(d$price, coef = 3)$out)) >= 1){
var.trans = "log2"
};
glob <- ddply(d, .(), summarise,
Volume=round(sum(qty),0),
Sales=round(sum(sales),0),
WeightedAvg=round(sum(sales)/sum(qty),4),
Mean=round(mean(price),4),
StdDev=round(sd(price),4),
Target=round(mean(target_price),4),
PriceMin = round(min(price),4),
PriceMax = round(max(maxprice),4),
VolumeMin = round(min(pmax(qty,volmin)),4),
VolumeMax = round(max(qty),1),
VolumeSD=round(sd(pmax(qty,volmin)),4)
);
targets <- ddply(d, .(dim1, dim2, plot,mold,chan,colgrp, brnd), summarise,
Volume=round(sum(qty),0),
Sales=round(sum(sales),0),
WeightedAvg=round(sum(sales)/sum(qty*1000),4),
Mean=round(mean(price),4),
StdDev=round(sd(price),4),
Target=round(mean(target_price),4)
);
seas <- ddply(d, .(dim1, dim2, plot, oseas), summarise,
Volume=round(sum(qty),0),
Sales=round(sum(sales),0),
WeightedAvg=round(sum(sales)/sum(qty*1000),4),
Mean=round(mean(price),4),
StdDev=round(sd(price),4),
Target=round(mean(target_price),4)
);
plist <- ddply(d, .(dim1, dim2, plot,mold,chan,colgrp, brnd), summarise,
List=round(mean(listprice),4)
);
#targets;
#-----------------blank dataframe in case there is no data for a scenario-----------------
blank <- glob
blank$customer = 'NO DATA'
blank$oseas = 2020
blank$season = '2020'
blank$qty = blank$VolumeSD
blank$price = blank$Mean
#blank;
yr1 <- subset(seas, oseas == 2020);
yr2 <- subset(seas, oseas == 2021);
dir_t <- subset(targets, chan == "DIR");
drp_t <- subset(targets, chan == "DRP");
whs_t <- subset(targets, chan == "WHS");
#create a single row for each plot that will hold relevant data
anno <- data.frame(unique(d[c("plot","dim2","dim1","mold","colgrp","brnd")]));
anno <- data.frame(anno,qty=c(Inf),price=c(Inf),hjustvar = c(1),vjustvar = c(1));
#merge in year 1 data
anno <- merge(x = anno, y = yr1[ , c("plot","Mean","WeightedAvg", "StdDev","Volume")], by = "plot", all.x=TRUE);
names(anno)[names(anno)=="Mean"] <- "yr1_mn";
names(anno)[names(anno)=="WeightedAvg"] <- "yr1_wa";
names(anno)[names(anno)=="StdDev"] <- "yr1_sd";
names(anno)[names(anno)=="Volume"] <- "yr1_vo";
#merge in year 2 data
anno <- merge(x = anno, y = yr2[ , c("plot","Mean","WeightedAvg", "StdDev","Volume")], by = "plot", all.x=TRUE);
names(anno)[names(anno)=="Mean"] <- "yr2_mn";
names(anno)[names(anno)=="WeightedAvg"] <- "yr2_wa";
names(anno)[names(anno)=="StdDev"] <- "yr2_sd";
names(anno)[names(anno)=="Volume"] <- "yr2_vo";
#merge in direct targes
anno <- merge(x = anno, y = dir_t[ , c("plot","Target")], by = "plot", all.x=TRUE);
names(anno)[names(anno)=="Target"] <- "t_dir";
#merge in drop ship targes
anno <- merge(x = anno, y = drp_t[ , c("plot","Target")], by = "plot", all.x=TRUE);
names(anno)[names(anno)=="Target"] <- "t_drp";
#merge in warehouse targes
anno <- merge(x = anno, y = whs_t[ , c("plot","Target")], by = "plot", all.x=TRUE);
names(anno)[names(anno)=="Target"] <- "t_whs";
#merge in pricelist
anno <- merge(x = anno, y = plist[ , c("plot","List")], by = "plot", all.x=TRUE);
names(anno)[names(anno)=="List"] <- "plist";
#anno;
#create a csv file of the anno table
# csv <- anno;
# csv <- subset(csv, select = c(mold, dim2, colgrp, brnd, yr1_mn, yr2_mn, yr1_wa, yr2_wa, t_dir, t_drp, t_whs));
# csv$t_dir_rev = csv$t_dir;
# csv$t_drp_rev = csv$t_drp;
# csv$t_whs_rev = csv$t_whs;
# names(csv)[names(csv)=="dim2"] <- "chgrp";
# csv;
# write.csv(csv, file = paste("//home/ptrowbridge/pt_share/",file_name,"_TRG.csv",sep=""), row.names = FALSE);
p=ggplot(d, aes(x=qty, y=price, color=sub)) +
geom_point(size=2) +
geom_text(data = anno,
aes(
x=qty,y=price,
color = NULL,
hjust=hjustvar,vjust=vjustvar,
label=paste(
" mean | wavg | stdd | vol \n",
"-------|--------|--------|---------\n",
"PY(black): ",
#----------mean-------------------------------
str_pad(
format(round(yr1_mn, 4), nsmall = 4),
width = 6,
side = "both",
pad = " "),
"|",
#----------weighted average-------------------
str_pad(
format(round(yr1_wa, 4), nsmall = 4),
width = 6,
side = "both",
pad = " "
),
#----------standard deviation-----------------
"|",
str_pad(
format(round(yr1_sd, 4), nsmall = 4),
width = 6,
side = "both",
pad = " "),
"|",
#----------volume-----------------------------
str_pad(
format(round(yr1_vo/1000, 4), nsmall = 4,width = 7),
width = 6,
side = "both",
pad = " "),
"\n",
"CY(green): ",
#----------mean-------------------------------
str_pad(
format(round(yr2_mn, 4), nsmall = 4),
width = 6,
side = "both",
pad = " "),
"|",
#----------weighted average-------------------
str_pad(
format(round(yr2_wa, 4), nsmall = 4),
width = 6,
side = "both",
pad = " "
),
#----------standard deviation-----------------
"|",
str_pad(
format(round(yr2_sd, 4), nsmall = 4),
width = 6,
side = "both",
pad = " "),
"|",
#----------volume-----------------------------
str_pad(
format(round(yr2_vo/1000, 4), nsmall = 4,width = 7),
width = 6,
side = "both",
pad = " "),
"\n","\n",
" | plist | change | % incr \n",
#----------price list-----------------------------
"PL (orange):",
str_pad(
format(" ", nsmall = 4),
width = 6,
side = "both",
pad = " "),"|",
str_pad(
format(round(plist,2), nsmall = 4),
width = 6,
side = "both",
pad = " "),"|",
str_pad(
format(round((plist-yr1_wa),3), nsmall = 4),
width = 6,
side = "both",
pad = " "),"|",
str_pad(
format(round((plist/yr1_wa-1),3)*100, nsmall = 1,width = 7),
width = 6,
side = "both",
pad = " "),"\n"
)
),
family="Courier",
size = 3
) +
geom_text(aes(label=customer),size=3, vjust = 2, hjust = 0, check_overlap=TRUE) +
facet_grid(dim2~dim1) +
#facet_grid(chgrp~plot) +
#facet_wrap(plot) +
#geom_hline(data=yr1, aes(yintercept=Mean),linetype="dashed", size=.5, colour="black") +
#geom_hline(data=yr1, aes(yintercept=Mean - StdDev),linetype="dashed", size=.5, colour="black") +
#geom_hline(data=yr1, aes(yintercept=Mean - StdDev * 2),linetype="dashed", size=.5, colour="black") +
geom_hline(data=yr1, aes(yintercept=WeightedAvg),linetype="solid", size=.5, colour="black") +
#geom_hline(data=yr2, aes(yintercept=Mean),linetype="dashed", size=.5, colour="green") +
#geom_hline(data=yr2, aes(yintercept=Mean - StdDev),linetype="dashed", size=.5, colour="green") +
#geom_hline(data=yr2, aes(yintercept=Mean - StdDev * 2),linetype="dashed", size=.5, colour="green") +
geom_hline(data=yr2, aes(yintercept=WeightedAvg),linetype="solid", size=.5, colour="green") +
geom_hline(data=dir_t, aes(yintercept=Target),linetype="solid", size=.5, colour="blue") +
geom_hline(data=drp_t, aes(yintercept=Target),linetype="solid", size=.5, colour="yellow") +
geom_hline(data=whs_t, aes(yintercept=Target),linetype="solid", size=.5, colour="red") +
geom_hline(data=plist, aes(yintercept=List),linetype="solid", size=.5, colour="orange") +
#scale_y_continuous(breaks=seq(0, 10, round(glob$StdDev * .5,2))) +
scale_y_continuous(
#breaks=seq(glob$PriceMin, glob$PriceMax, round(glob$StdDev * .5,4)),
breaks = pretty_breaks(n=20),
limits = c(glob$PriceMin, glob$PriceMax), trans = ytrans
) +
scale_x_continuous(
#breaks=seq(glob$VolumeMin, glob$VolumeMax, round(glob$VolumeSD * 1.0,4)),
breaks = pretty_breaks(n=10),
limits = c(glob$VolumeMin, glob$VolumeMax*1.1), trans = xtrans
) +
#scale_x_continuous(trans='log2') +
#scale_x_continuous(breaks=seq(0,1000,round(glob$VolumeSD * 1,2)), trans = 'log2') +
#geom_label(colour = "white", fontface = "bold") +
#geom_text(aes(label=ds$ship_group),position = position_dodge(width=.9), size=2) +
theme(legend.position="none");
cp_pvt = p + theme_bw();
#targets;
options(
repr.plot.width=var.dim1*xfact,
repr.plot.height=var.dim2*yfact
);
cp_pvt;
#plist;