df<- read.csv("DATA/Sample - Superstore.csv")
head (df)
##   Row.ID       Order.ID Order.Date  Ship.Date      Ship.Mode Customer.ID
## 1      1 CA-2016-152156  11/8/2016 11/11/2016   Second Class    CG-12520
## 2      2 CA-2016-152156  11/8/2016 11/11/2016   Second Class    CG-12520
## 3      3 CA-2016-138688  6/12/2016  6/16/2016   Second Class    DV-13045
## 4      4 US-2015-108966 10/11/2015 10/18/2015 Standard Class    SO-20335
## 5      5 US-2015-108966 10/11/2015 10/18/2015 Standard Class    SO-20335
## 6      6 CA-2014-115812   6/9/2014  6/14/2014 Standard Class    BH-11710
##     Customer.Name   Segment       Country            City      State
## 1     Claire Gute  Consumer United States       Henderson   Kentucky
## 2     Claire Gute  Consumer United States       Henderson   Kentucky
## 3 Darrin Van Huff Corporate United States     Los Angeles California
## 4  Sean O'Donnell  Consumer United States Fort Lauderdale    Florida
## 5  Sean O'Donnell  Consumer United States Fort Lauderdale    Florida
## 6 Brosina Hoffman  Consumer United States     Los Angeles California
##   Postal.Code Region      Product.ID        Category Sub.Category
## 1       42420  South FUR-BO-10001798       Furniture    Bookcases
## 2       42420  South FUR-CH-10000454       Furniture       Chairs
## 3       90036   West OFF-LA-10000240 Office Supplies       Labels
## 4       33311  South FUR-TA-10000577       Furniture       Tables
## 5       33311  South OFF-ST-10000760 Office Supplies      Storage
## 6       90032   West FUR-FU-10001487       Furniture  Furnishings
##                                                       Product.Name    Sales
## 1                                Bush Somerset Collection Bookcase 261.9600
## 2      Hon Deluxe Fabric Upholstered Stacking Chairs, Rounded Back 731.9400
## 3        Self-Adhesive Address Labels for Typewriters by Universal  14.6200
## 4                    Bretford CR4500 Series Slim Rectangular Table 957.5775
## 5                                   Eldon Fold 'N Roll Cart System  22.3680
## 6 Eldon Expressions Wood and Plastic Desk Accessories, Cherry Wood  48.8600
##   Quantity Discount    Profit
## 1        2     0.00   41.9136
## 2        3     0.00  219.5820
## 3        2     0.00    6.8714
## 4        5     0.45 -383.0310
## 5        2     0.20    2.5164
## 6        7     0.00   14.1694

2.2 funciones y paquetes de R para análisis de datos

2.2.1 arrange ()

df <- df %>%
  mutate(Order.Date=mdy(Order.Date)) %>%
  mutate(Ship.Date=mdy(Ship.Date)) %>%
  arrange(Order.Date)
head(df)
##   Row.ID       Order.ID Order.Date  Ship.Date      Ship.Mode Customer.ID
## 1   7981 CA-2014-103800 2014-01-03 2014-01-07 Standard Class    DP-13000
## 2    740 CA-2014-112326 2014-01-04 2014-01-08 Standard Class    PO-19195
## 3    741 CA-2014-112326 2014-01-04 2014-01-08 Standard Class    PO-19195
## 4    742 CA-2014-112326 2014-01-04 2014-01-08 Standard Class    PO-19195
## 5   1760 CA-2014-141817 2014-01-05 2014-01-12 Standard Class    MB-18085
## 6   5328 CA-2014-130813 2014-01-06 2014-01-08   Second Class    LS-17230
##      Customer.Name     Segment       Country         City        State
## 1    Darren Powers    Consumer United States      Houston        Texas
## 2    Phillina Ober Home Office United States   Naperville     Illinois
## 3    Phillina Ober Home Office United States   Naperville     Illinois
## 4    Phillina Ober Home Office United States   Naperville     Illinois
## 5       Mick Brown    Consumer United States Philadelphia Pennsylvania
## 6 Lycoris Saunders    Consumer United States  Los Angeles   California
##   Postal.Code  Region      Product.ID        Category Sub.Category
## 1       77095 Central OFF-PA-10000174 Office Supplies        Paper
## 2       60540 Central OFF-LA-10003223 Office Supplies       Labels
## 3       60540 Central OFF-ST-10002743 Office Supplies      Storage
## 4       60540 Central OFF-BI-10004094 Office Supplies      Binders
## 5       19143    East OFF-AR-10003478 Office Supplies          Art
## 6       90049    West OFF-PA-10002005 Office Supplies        Paper
##                                                               Product.Name
## 1 Message Book, Wirebound, Four 5 1/2" X 4" Forms/Pg., 200 Dupl. Sets/Book
## 2                                                                Avery 508
## 3                                            SAFCO Boltless Steel Shelving
## 4                               GBC Standard Plastic Binding Systems Combs
## 5       Avery Hi-Liter EverBold Pen Style Fluorescent Highlighters, 4/Pack
## 6                                                                Xerox 225
##     Sales Quantity Discount   Profit
## 1  16.448        2      0.2   5.5512
## 2  11.784        3      0.2   4.2717
## 3 272.736        3      0.2 -64.7748
## 4   3.540        2      0.8  -5.4870
## 5  19.536        3      0.2   4.8840
## 6  19.440        3      0.0   9.3312

2.2.2 as.character()

df <- df %>%
  mutate(Postal.Code=as.character(Postal.Code))
head(df)
##   Row.ID       Order.ID Order.Date  Ship.Date      Ship.Mode Customer.ID
## 1   7981 CA-2014-103800 2014-01-03 2014-01-07 Standard Class    DP-13000
## 2    740 CA-2014-112326 2014-01-04 2014-01-08 Standard Class    PO-19195
## 3    741 CA-2014-112326 2014-01-04 2014-01-08 Standard Class    PO-19195
## 4    742 CA-2014-112326 2014-01-04 2014-01-08 Standard Class    PO-19195
## 5   1760 CA-2014-141817 2014-01-05 2014-01-12 Standard Class    MB-18085
## 6   5328 CA-2014-130813 2014-01-06 2014-01-08   Second Class    LS-17230
##      Customer.Name     Segment       Country         City        State
## 1    Darren Powers    Consumer United States      Houston        Texas
## 2    Phillina Ober Home Office United States   Naperville     Illinois
## 3    Phillina Ober Home Office United States   Naperville     Illinois
## 4    Phillina Ober Home Office United States   Naperville     Illinois
## 5       Mick Brown    Consumer United States Philadelphia Pennsylvania
## 6 Lycoris Saunders    Consumer United States  Los Angeles   California
##   Postal.Code  Region      Product.ID        Category Sub.Category
## 1       77095 Central OFF-PA-10000174 Office Supplies        Paper
## 2       60540 Central OFF-LA-10003223 Office Supplies       Labels
## 3       60540 Central OFF-ST-10002743 Office Supplies      Storage
## 4       60540 Central OFF-BI-10004094 Office Supplies      Binders
## 5       19143    East OFF-AR-10003478 Office Supplies          Art
## 6       90049    West OFF-PA-10002005 Office Supplies        Paper
##                                                               Product.Name
## 1 Message Book, Wirebound, Four 5 1/2" X 4" Forms/Pg., 200 Dupl. Sets/Book
## 2                                                                Avery 508
## 3                                            SAFCO Boltless Steel Shelving
## 4                               GBC Standard Plastic Binding Systems Combs
## 5       Avery Hi-Liter EverBold Pen Style Fluorescent Highlighters, 4/Pack
## 6                                                                Xerox 225
##     Sales Quantity Discount   Profit
## 1  16.448        2      0.2   5.5512
## 2  11.784        3      0.2   4.2717
## 3 272.736        3      0.2 -64.7748
## 4   3.540        2      0.8  -5.4870
## 5  19.536        3      0.2   4.8840
## 6  19.440        3      0.0   9.3312

2.2.3 as.factor()

#La creación de factores facilita la división
#de la base de datos en grupos.
#Acelera el cómputo
df <- df %>%
  mutate(Ship.Mode=as.factor(Ship.Mode)) %>%
  mutate(Segment=as.factor(Segment)) %>%
  mutate(Country=as.factor(Country)) %>%
  mutate(City=as.factor(City)) %>%
  mutate(State=as.factor(State)) %>%
  mutate(Region=as.factor(Region)) %>%
  mutate(Category=as.factor(Category)) %>%
  mutate(Sub.Category=as.factor(Sub.Category))
head(df)
##   Row.ID       Order.ID Order.Date  Ship.Date      Ship.Mode Customer.ID
## 1   7981 CA-2014-103800 2014-01-03 2014-01-07 Standard Class    DP-13000
## 2    740 CA-2014-112326 2014-01-04 2014-01-08 Standard Class    PO-19195
## 3    741 CA-2014-112326 2014-01-04 2014-01-08 Standard Class    PO-19195
## 4    742 CA-2014-112326 2014-01-04 2014-01-08 Standard Class    PO-19195
## 5   1760 CA-2014-141817 2014-01-05 2014-01-12 Standard Class    MB-18085
## 6   5328 CA-2014-130813 2014-01-06 2014-01-08   Second Class    LS-17230
##      Customer.Name     Segment       Country         City        State
## 1    Darren Powers    Consumer United States      Houston        Texas
## 2    Phillina Ober Home Office United States   Naperville     Illinois
## 3    Phillina Ober Home Office United States   Naperville     Illinois
## 4    Phillina Ober Home Office United States   Naperville     Illinois
## 5       Mick Brown    Consumer United States Philadelphia Pennsylvania
## 6 Lycoris Saunders    Consumer United States  Los Angeles   California
##   Postal.Code  Region      Product.ID        Category Sub.Category
## 1       77095 Central OFF-PA-10000174 Office Supplies        Paper
## 2       60540 Central OFF-LA-10003223 Office Supplies       Labels
## 3       60540 Central OFF-ST-10002743 Office Supplies      Storage
## 4       60540 Central OFF-BI-10004094 Office Supplies      Binders
## 5       19143    East OFF-AR-10003478 Office Supplies          Art
## 6       90049    West OFF-PA-10002005 Office Supplies        Paper
##                                                               Product.Name
## 1 Message Book, Wirebound, Four 5 1/2" X 4" Forms/Pg., 200 Dupl. Sets/Book
## 2                                                                Avery 508
## 3                                            SAFCO Boltless Steel Shelving
## 4                               GBC Standard Plastic Binding Systems Combs
## 5       Avery Hi-Liter EverBold Pen Style Fluorescent Highlighters, 4/Pack
## 6                                                                Xerox 225
##     Sales Quantity Discount   Profit
## 1  16.448        2      0.2   5.5512
## 2  11.784        3      0.2   4.2717
## 3 272.736        3      0.2 -64.7748
## 4   3.540        2      0.8  -5.4870
## 5  19.536        3      0.2   4.8840
## 6  19.440        3      0.0   9.3312

2.2.4 as.numeric()

df %>%
  select(Sales, Quantity, Discount, Profit) %>%
  mutate_all(as.numeric) %>%
  head(.)
##     Sales Quantity Discount   Profit
## 1  16.448        2      0.2   5.5512
## 2  11.784        3      0.2   4.2717
## 3 272.736        3      0.2 -64.7748
## 4   3.540        2      0.8  -5.4870
## 5  19.536        3      0.2   4.8840
## 6  19.440        3      0.0   9.3312
#aplica función head a lo queda de lo anterior

2.2.5 class()

#Permite evaluar el tipo de clase de objetos y el tipo de datos de columnas
class(df)
## [1] "data.frame"
#permite conocer el tipo de dato de una columna
class(df$Order.Date)
## [1] "Date"

2.2.6 day ()

#Sirve para recuperar el dia de una columna guardada como fecha 
df %>%
select(Order.Date) %>%
  mutate(Day.Order=day(Order.Date)) %>%
  mutate(Week.Order=week(Order.Date)) %>%
  mutate(Month.Order=month(Order.Date)) %>%
  mutate(Year.Order=year(Order.Date)) %>%
  head(.)
##   Order.Date Day.Order Week.Order Month.Order Year.Order
## 1 2014-01-03         3          1           1       2014
## 2 2014-01-04         4          1           1       2014
## 3 2014-01-04         4          1           1       2014
## 4 2014-01-04         4          1           1       2014
## 5 2014-01-05         5          1           1       2014
## 6 2014-01-06         6          1           1       2014

2.2.7 dym()

# Me permite convertir texto tipo date
dmy("30/08/2024")
## [1] "2024-08-30"
# Tener cuidado de orden en el que está almacenada la fecha
dmy("30/08/2024")
## [1] "2024-08-30"
mdy("30/08/2024") # NA aparece porque no hay mes 30
## Warning: All formats failed to parse. No formats found.
## [1] NA

2.2.8 filter()

# Me permite obtenerrangos de datos por fechas
df %>%
  filter(year(Order.Date) < 2015) %>% #filtrar usando función
  head(.)
##   Row.ID       Order.ID Order.Date  Ship.Date      Ship.Mode Customer.ID
## 1   7981 CA-2014-103800 2014-01-03 2014-01-07 Standard Class    DP-13000
## 2    740 CA-2014-112326 2014-01-04 2014-01-08 Standard Class    PO-19195
## 3    741 CA-2014-112326 2014-01-04 2014-01-08 Standard Class    PO-19195
## 4    742 CA-2014-112326 2014-01-04 2014-01-08 Standard Class    PO-19195
## 5   1760 CA-2014-141817 2014-01-05 2014-01-12 Standard Class    MB-18085
## 6   5328 CA-2014-130813 2014-01-06 2014-01-08   Second Class    LS-17230
##      Customer.Name     Segment       Country         City        State
## 1    Darren Powers    Consumer United States      Houston        Texas
## 2    Phillina Ober Home Office United States   Naperville     Illinois
## 3    Phillina Ober Home Office United States   Naperville     Illinois
## 4    Phillina Ober Home Office United States   Naperville     Illinois
## 5       Mick Brown    Consumer United States Philadelphia Pennsylvania
## 6 Lycoris Saunders    Consumer United States  Los Angeles   California
##   Postal.Code  Region      Product.ID        Category Sub.Category
## 1       77095 Central OFF-PA-10000174 Office Supplies        Paper
## 2       60540 Central OFF-LA-10003223 Office Supplies       Labels
## 3       60540 Central OFF-ST-10002743 Office Supplies      Storage
## 4       60540 Central OFF-BI-10004094 Office Supplies      Binders
## 5       19143    East OFF-AR-10003478 Office Supplies          Art
## 6       90049    West OFF-PA-10002005 Office Supplies        Paper
##                                                               Product.Name
## 1 Message Book, Wirebound, Four 5 1/2" X 4" Forms/Pg., 200 Dupl. Sets/Book
## 2                                                                Avery 508
## 3                                            SAFCO Boltless Steel Shelving
## 4                               GBC Standard Plastic Binding Systems Combs
## 5       Avery Hi-Liter EverBold Pen Style Fluorescent Highlighters, 4/Pack
## 6                                                                Xerox 225
##     Sales Quantity Discount   Profit
## 1  16.448        2      0.2   5.5512
## 2  11.784        3      0.2   4.2717
## 3 272.736        3      0.2 -64.7748
## 4   3.540        2      0.8  -5.4870
## 5  19.536        3      0.2   4.8840
## 6  19.440        3      0.0   9.3312
# Filtrar a partir de una fecha especifica 15 sep del 2017
df %>%
  filter(Order.Date < ymd("2017/09/15")) %>%
head(.)
##   Row.ID       Order.ID Order.Date  Ship.Date      Ship.Mode Customer.ID
## 1   7981 CA-2014-103800 2014-01-03 2014-01-07 Standard Class    DP-13000
## 2    740 CA-2014-112326 2014-01-04 2014-01-08 Standard Class    PO-19195
## 3    741 CA-2014-112326 2014-01-04 2014-01-08 Standard Class    PO-19195
## 4    742 CA-2014-112326 2014-01-04 2014-01-08 Standard Class    PO-19195
## 5   1760 CA-2014-141817 2014-01-05 2014-01-12 Standard Class    MB-18085
## 6   5328 CA-2014-130813 2014-01-06 2014-01-08   Second Class    LS-17230
##      Customer.Name     Segment       Country         City        State
## 1    Darren Powers    Consumer United States      Houston        Texas
## 2    Phillina Ober Home Office United States   Naperville     Illinois
## 3    Phillina Ober Home Office United States   Naperville     Illinois
## 4    Phillina Ober Home Office United States   Naperville     Illinois
## 5       Mick Brown    Consumer United States Philadelphia Pennsylvania
## 6 Lycoris Saunders    Consumer United States  Los Angeles   California
##   Postal.Code  Region      Product.ID        Category Sub.Category
## 1       77095 Central OFF-PA-10000174 Office Supplies        Paper
## 2       60540 Central OFF-LA-10003223 Office Supplies       Labels
## 3       60540 Central OFF-ST-10002743 Office Supplies      Storage
## 4       60540 Central OFF-BI-10004094 Office Supplies      Binders
## 5       19143    East OFF-AR-10003478 Office Supplies          Art
## 6       90049    West OFF-PA-10002005 Office Supplies        Paper
##                                                               Product.Name
## 1 Message Book, Wirebound, Four 5 1/2" X 4" Forms/Pg., 200 Dupl. Sets/Book
## 2                                                                Avery 508
## 3                                            SAFCO Boltless Steel Shelving
## 4                               GBC Standard Plastic Binding Systems Combs
## 5       Avery Hi-Liter EverBold Pen Style Fluorescent Highlighters, 4/Pack
## 6                                                                Xerox 225
##     Sales Quantity Discount   Profit
## 1  16.448        2      0.2   5.5512
## 2  11.784        3      0.2   4.2717
## 3 272.736        3      0.2 -64.7748
## 4   3.540        2      0.8  -5.4870
## 5  19.536        3      0.2   4.8840
## 6  19.440        3      0.0   9.3312
# Quiero ventas estado de Michigan
df %>%
  filter(State == "Michigan") %>%
head(.)
##   Row.ID       Order.ID Order.Date  Ship.Date      Ship.Mode Customer.ID
## 1   6327 CA-2014-167927 2014-01-20 2014-01-26 Standard Class    XP-21865
## 2   6328 CA-2014-167927 2014-01-20 2014-01-26 Standard Class    XP-21865
## 3   6329 CA-2014-167927 2014-01-20 2014-01-26 Standard Class    XP-21865
## 4   6330 CA-2014-167927 2014-01-20 2014-01-26 Standard Class    XP-21865
## 5   6331 CA-2014-167927 2014-01-20 2014-01-26 Standard Class    XP-21865
## 6   6332 CA-2014-167927 2014-01-20 2014-01-26 Standard Class    XP-21865
##   Customer.Name  Segment       Country     City    State Postal.Code  Region
## 1  Xylona Preis Consumer United States Westland Michigan       48185 Central
## 2  Xylona Preis Consumer United States Westland Michigan       48185 Central
## 3  Xylona Preis Consumer United States Westland Michigan       48185 Central
## 4  Xylona Preis Consumer United States Westland Michigan       48185 Central
## 5  Xylona Preis Consumer United States Westland Michigan       48185 Central
## 6  Xylona Preis Consumer United States Westland Michigan       48185 Central
##        Product.ID        Category Sub.Category
## 1 OFF-ST-10000760 Office Supplies      Storage
## 2 FUR-FU-10002918       Furniture  Furnishings
## 3 OFF-BI-10000605 Office Supplies      Binders
## 4 OFF-AP-10002311 Office Supplies   Appliances
## 5 OFF-ST-10003123 Office Supplies      Storage
## 6 OFF-AR-10004456 Office Supplies          Art
##                                                                   Product.Name
## 1                                               Eldon Fold 'N Roll Cart System
## 2               Eldon ClusterMat Chair Mat with Cordless Antistatic Protection
## 3       Acco Pressboard Covers with Storage Hooks, 9 1/2" x 11", Executive Red
## 4 Holmes Replacement Filter for HEPA Air Cleaner, Very Large Room, HEPA Filter
## 5                    Fellowes Bases and Tops For Staxonsteel/High-Stak Systems
## 6                          Panasonic KP-4ABK Battery-Operated Pencil Sharpener
##     Sales Quantity Discount  Profit
## 1  13.980        1      0.0  4.0542
## 2 272.940        3      0.0 30.0234
## 3  19.050        5      0.0  8.9535
## 4 247.716        4      0.1 93.5816
## 5  66.580        2      0.0 15.9792
## 6  43.920        3      0.0 12.7368
# Quiero ventas excepto estado de Michigan
df %>%
filter(State != "Michigan") %>%
  head(.)
##   Row.ID       Order.ID Order.Date  Ship.Date      Ship.Mode Customer.ID
## 1   7981 CA-2014-103800 2014-01-03 2014-01-07 Standard Class    DP-13000
## 2    740 CA-2014-112326 2014-01-04 2014-01-08 Standard Class    PO-19195
## 3    741 CA-2014-112326 2014-01-04 2014-01-08 Standard Class    PO-19195
## 4    742 CA-2014-112326 2014-01-04 2014-01-08 Standard Class    PO-19195
## 5   1760 CA-2014-141817 2014-01-05 2014-01-12 Standard Class    MB-18085
## 6   5328 CA-2014-130813 2014-01-06 2014-01-08   Second Class    LS-17230
##      Customer.Name     Segment       Country         City        State
## 1    Darren Powers    Consumer United States      Houston        Texas
## 2    Phillina Ober Home Office United States   Naperville     Illinois
## 3    Phillina Ober Home Office United States   Naperville     Illinois
## 4    Phillina Ober Home Office United States   Naperville     Illinois
## 5       Mick Brown    Consumer United States Philadelphia Pennsylvania
## 6 Lycoris Saunders    Consumer United States  Los Angeles   California
##   Postal.Code  Region      Product.ID        Category Sub.Category
## 1       77095 Central OFF-PA-10000174 Office Supplies        Paper
## 2       60540 Central OFF-LA-10003223 Office Supplies       Labels
## 3       60540 Central OFF-ST-10002743 Office Supplies      Storage
## 4       60540 Central OFF-BI-10004094 Office Supplies      Binders
## 5       19143    East OFF-AR-10003478 Office Supplies          Art
## 6       90049    West OFF-PA-10002005 Office Supplies        Paper
##                                                               Product.Name
## 1 Message Book, Wirebound, Four 5 1/2" X 4" Forms/Pg., 200 Dupl. Sets/Book
## 2                                                                Avery 508
## 3                                            SAFCO Boltless Steel Shelving
## 4                               GBC Standard Plastic Binding Systems Combs
## 5       Avery Hi-Liter EverBold Pen Style Fluorescent Highlighters, 4/Pack
## 6                                                                Xerox 225
##     Sales Quantity Discount   Profit
## 1  16.448        2      0.2   5.5512
## 2  11.784        3      0.2   4.2717
## 3 272.736        3      0.2 -64.7748
## 4   3.540        2      0.8  -5.4870
## 5  19.536        3      0.2   4.8840
## 6  19.440        3      0.0   9.3312
# Filtrar los clientes de apellido Brown
df %>%
  filter(grepl("Brown", Customer.Name))
## Warning: There were 94 warnings in `filter()`.
## The first warning was:
## ℹ In argument: `grepl("Brown", Customer.Name)`.
## Caused by warning in `grepl()`:
## ! unable to translate 'Barry Franz<f6>sisch' to a wide string
## ℹ Run `dplyr::last_dplyr_warnings()` to see the 93 remaining warnings.
##    Row.ID       Order.ID Order.Date  Ship.Date      Ship.Mode Customer.ID
## 1    1760 CA-2014-141817 2014-01-05 2014-01-12 Standard Class    MB-18085
## 2    2996 US-2014-150532 2014-07-14 2014-07-21 Standard Class    PB-19150
## 3    8544 CA-2014-137575 2014-08-06 2014-08-11 Standard Class    TB-21625
## 4    8867 CA-2014-120411 2014-09-20 2014-09-23    First Class    SB-20185
## 5    8868 CA-2014-120411 2014-09-20 2014-09-23    First Class    SB-20185
## 6    4309 CA-2014-125829 2014-11-04 2014-11-11 Standard Class    WB-21850
## 7    4310 CA-2014-125829 2014-11-04 2014-11-11 Standard Class    WB-21850
## 8    4311 CA-2014-125829 2014-11-04 2014-11-11 Standard Class    WB-21850
## 9    4312 CA-2014-125829 2014-11-04 2014-11-11 Standard Class    WB-21850
## 10   4313 CA-2014-125829 2014-11-04 2014-11-11 Standard Class    WB-21850
## 11   7786 US-2014-111353 2014-11-29 2014-12-06 Standard Class    PB-19150
## 12   9195 CA-2014-146843 2014-11-30 2014-12-06 Standard Class    PB-19150
## 13   9196 CA-2014-146843 2014-11-30 2014-12-06 Standard Class    PB-19150
## 14   2149 CA-2014-141607 2014-12-12 2014-12-17 Standard Class    WB-21850
## 15   5486 CA-2014-107573 2014-12-12 2014-12-17 Standard Class    PB-19150
## 16   6107 CA-2014-120852 2014-12-20 2014-12-25 Standard Class    WB-21850
## 17   6108 CA-2014-120852 2014-12-20 2014-12-25 Standard Class    WB-21850
## 18   4857 CA-2015-137526 2015-01-13 2015-01-17 Standard Class    PB-19150
## 19   4858 CA-2015-137526 2015-01-13 2015-01-17 Standard Class    PB-19150
## 20   4859 CA-2015-137526 2015-01-13 2015-01-17 Standard Class    PB-19150
## 21   6201 CA-2015-146675 2015-04-16 2015-04-20 Standard Class    SB-20185
## 22   6202 CA-2015-146675 2015-04-16 2015-04-20 Standard Class    SB-20185
## 23   8102 CA-2015-149846 2015-05-22 2015-05-26 Standard Class    SB-20185
## 24   8103 CA-2015-149846 2015-05-22 2015-05-26 Standard Class    SB-20185
## 25   8104 CA-2015-149846 2015-05-22 2015-05-26 Standard Class    SB-20185
## 26   8105 CA-2015-149846 2015-05-22 2015-05-26 Standard Class    SB-20185
## 27   8387 CA-2015-149601 2015-05-28 2015-06-03 Standard Class    TB-21625
## 28   8388 CA-2015-149601 2015-05-28 2015-06-03 Standard Class    TB-21625
## 29   1024 CA-2015-167269 2015-06-16 2015-06-20 Standard Class    PB-19150
## 30   6644 US-2015-156496 2015-08-10 2015-08-16 Standard Class    WB-21850
## 31   6645 US-2015-156496 2015-08-10 2015-08-16 Standard Class    WB-21850
## 32   6646 US-2015-156496 2015-08-10 2015-08-16 Standard Class    WB-21850
## 33   5597 CA-2015-159779 2015-09-25 2015-09-29 Standard Class    SB-20185
## 34   4381 CA-2015-152891 2015-10-25 2015-10-30 Standard Class    TB-21625
## 35   4382 CA-2015-152891 2015-10-25 2015-10-30 Standard Class    TB-21625
## 36   2134 CA-2015-122210 2015-11-30 2015-12-04 Standard Class    WB-21850
## 37   2135 CA-2015-122210 2015-11-30 2015-12-04 Standard Class    WB-21850
## 38   2136 CA-2015-122210 2015-11-30 2015-12-04 Standard Class    WB-21850
## 39   2137 CA-2015-156377 2015-12-31 2016-01-05 Standard Class    TB-21625
## 40   2138 CA-2015-156377 2015-12-31 2016-01-05 Standard Class    TB-21625
## 41   3742 CA-2016-137848 2016-01-15 2016-01-21 Standard Class    WB-21850
## 42   3743 CA-2016-137848 2016-01-15 2016-01-21 Standard Class    WB-21850
## 43   3744 CA-2016-137848 2016-01-15 2016-01-21 Standard Class    WB-21850
## 44   1462 US-2016-128902 2016-03-11 2016-03-15 Standard Class    MB-18085
## 45    418 CA-2016-148796 2016-04-14 2016-04-18 Standard Class    PB-19150
## 46   4815 CA-2016-111696 2016-05-08 2016-05-10    First Class    TB-21625
## 47   7833 CA-2016-112382 2016-05-09 2016-05-13 Standard Class    MB-18085
## 48   9073 CA-2016-142524 2016-09-04 2016-09-08 Standard Class    MB-18085
## 49   9074 CA-2016-142524 2016-09-04 2016-09-08 Standard Class    MB-18085
## 50   5414 CA-2016-153157 2016-09-11 2016-09-14    First Class    TB-21625
## 51   9835 CA-2016-126627 2016-10-10 2016-10-12    First Class    WB-21850
## 52   9836 CA-2016-126627 2016-10-10 2016-10-12    First Class    WB-21850
## 53   7051 CA-2016-165330 2016-12-11 2016-12-11       Same Day    WB-21850
## 54   7052 CA-2016-165330 2016-12-11 2016-12-11       Same Day    WB-21850
## 55   7053 CA-2016-165330 2016-12-11 2016-12-11       Same Day    WB-21850
## 56   7054 CA-2016-165330 2016-12-11 2016-12-11       Same Day    WB-21850
## 57   7055 CA-2016-165330 2016-12-11 2016-12-11       Same Day    WB-21850
## 58   7056 CA-2016-165330 2016-12-11 2016-12-11       Same Day    WB-21850
## 59   7057 CA-2016-165330 2016-12-11 2016-12-11       Same Day    WB-21850
## 60   7058 CA-2016-165330 2016-12-11 2016-12-11       Same Day    WB-21850
## 61   7059 CA-2016-165330 2016-12-11 2016-12-11       Same Day    WB-21850
## 62   7060 CA-2016-165330 2016-12-11 2016-12-11       Same Day    WB-21850
## 63   7061 CA-2016-165330 2016-12-11 2016-12-11       Same Day    WB-21850
## 64   5075 CA-2017-151071 2017-04-25 2017-04-29   Second Class    MB-18085
## 65   6635 CA-2017-144498 2017-05-06 2017-05-06       Same Day    MB-18085
## 66   6636 CA-2017-144498 2017-05-06 2017-05-06       Same Day    MB-18085
## 67   6637 CA-2017-144498 2017-05-06 2017-05-06       Same Day    MB-18085
## 68   8013 CA-2017-120168 2017-05-25 2017-05-25       Same Day    TB-21625
## 69   8014 CA-2017-120168 2017-05-25 2017-05-25       Same Day    TB-21625
## 70   8015 CA-2017-120168 2017-05-25 2017-05-25       Same Day    TB-21625
## 71   8016 CA-2017-120168 2017-05-25 2017-05-25       Same Day    TB-21625
## 72   9175 CA-2017-119424 2017-06-12 2017-06-14   Second Class    SB-20185
## 73   9176 CA-2017-119424 2017-06-12 2017-06-14   Second Class    SB-20185
## 74   9584 CA-2017-116127 2017-06-25 2017-06-27   Second Class    SB-20185
## 75   4708 CA-2017-138149 2017-06-29 2017-06-30    First Class    WB-21850
## 76   4709 CA-2017-138149 2017-06-29 2017-06-30    First Class    WB-21850
## 77   4710 CA-2017-138149 2017-06-29 2017-06-30    First Class    WB-21850
## 78   4711 CA-2017-138149 2017-06-29 2017-06-30    First Class    WB-21850
## 79   8485 CA-2017-142391 2017-09-24 2017-09-24       Same Day    PB-19150
## 80   4227 CA-2017-120327 2017-11-11 2017-11-16 Standard Class    WB-21850
## 81   7589 CA-2017-122945 2017-11-16 2017-11-22 Standard Class    MB-18085
## 82   9294 US-2017-116505 2017-11-17 2017-11-21   Second Class    TB-21625
## 83   9289 US-2017-165456 2017-11-30 2017-12-03    First Class    TB-21625
## 84   9410 US-2017-110149 2017-12-10 2017-12-13    First Class    WB-21850
## 85   9411 US-2017-110149 2017-12-10 2017-12-13    First Class    WB-21850
##    Customer.Name  Segment       Country          City          State
## 1     Mick Brown Consumer United States  Philadelphia   Pennsylvania
## 2   Philip Brown Consumer United States       Phoenix        Arizona
## 3    Trudy Brown Consumer United States New York City       New York
## 4    Sarah Brown Consumer United States       Chicago       Illinois
## 5    Sarah Brown Consumer United States       Chicago       Illinois
## 6  William Brown Consumer United States   Los Angeles     California
## 7  William Brown Consumer United States   Los Angeles     California
## 8  William Brown Consumer United States   Los Angeles     California
## 9  William Brown Consumer United States   Los Angeles     California
## 10 William Brown Consumer United States   Los Angeles     California
## 11  Philip Brown Consumer United States New York City       New York
## 12  Philip Brown Consumer United States      Avondale        Arizona
## 13  Philip Brown Consumer United States      Avondale        Arizona
## 14 William Brown Consumer United States       Concord     California
## 15  Philip Brown Consumer United States         Miami        Florida
## 16 William Brown Consumer United States Grand Prairie          Texas
## 17 William Brown Consumer United States Grand Prairie          Texas
## 18  Philip Brown Consumer United States   Los Angeles     California
## 19  Philip Brown Consumer United States   Los Angeles     California
## 20  Philip Brown Consumer United States   Los Angeles     California
## 21   Sarah Brown Consumer United States      Evanston       Illinois
## 22   Sarah Brown Consumer United States      Evanston       Illinois
## 23   Sarah Brown Consumer United States   Los Angeles     California
## 24   Sarah Brown Consumer United States   Los Angeles     California
## 25   Sarah Brown Consumer United States   Los Angeles     California
## 26   Sarah Brown Consumer United States   Los Angeles     California
## 27   Trudy Brown Consumer United States    Manchester    Connecticut
## 28   Trudy Brown Consumer United States    Manchester    Connecticut
## 29  Philip Brown Consumer United States  Philadelphia   Pennsylvania
## 30 William Brown Consumer United States       Redmond         Oregon
## 31 William Brown Consumer United States       Redmond         Oregon
## 32 William Brown Consumer United States       Redmond         Oregon
## 33   Sarah Brown Consumer United States       Concord  New Hampshire
## 34   Trudy Brown Consumer United States San Francisco     California
## 35   Trudy Brown Consumer United States San Francisco     California
## 36 William Brown Consumer United States  Philadelphia   Pennsylvania
## 37 William Brown Consumer United States  Philadelphia   Pennsylvania
## 38 William Brown Consumer United States  Philadelphia   Pennsylvania
## 39   Trudy Brown Consumer United States Grand Prairie          Texas
## 40   Trudy Brown Consumer United States Grand Prairie          Texas
## 41 William Brown Consumer United States New York City       New York
## 42 William Brown Consumer United States New York City       New York
## 43 William Brown Consumer United States New York City       New York
## 44    Mick Brown Consumer United States      Vineland     New Jersey
## 45  Philip Brown Consumer United States   Los Angeles     California
## 46   Trudy Brown Consumer United States   Los Angeles     California
## 47    Mick Brown Consumer United States       Houston          Texas
## 48    Mick Brown Consumer United States   Springfield       Missouri
## 49    Mick Brown Consumer United States   Springfield       Missouri
## 50   Trudy Brown Consumer United States       Wichita         Kansas
## 51 William Brown Consumer United States      La Porte          Texas
## 52 William Brown Consumer United States      La Porte          Texas
## 53 William Brown Consumer United States       Anaheim     California
## 54 William Brown Consumer United States       Anaheim     California
## 55 William Brown Consumer United States       Anaheim     California
## 56 William Brown Consumer United States       Anaheim     California
## 57 William Brown Consumer United States       Anaheim     California
## 58 William Brown Consumer United States       Anaheim     California
## 59 William Brown Consumer United States       Anaheim     California
## 60 William Brown Consumer United States       Anaheim     California
## 61 William Brown Consumer United States       Anaheim     California
## 62 William Brown Consumer United States       Anaheim     California
## 63 William Brown Consumer United States       Anaheim     California
## 64    Mick Brown Consumer United States   Los Angeles     California
## 65    Mick Brown Consumer United States     Charlotte North Carolina
## 66    Mick Brown Consumer United States     Charlotte North Carolina
## 67    Mick Brown Consumer United States     Charlotte North Carolina
## 68   Trudy Brown Consumer United States New York City       New York
## 69   Trudy Brown Consumer United States New York City       New York
## 70   Trudy Brown Consumer United States New York City       New York
## 71   Trudy Brown Consumer United States New York City       New York
## 72   Sarah Brown Consumer United States          Kent     Washington
## 73   Sarah Brown Consumer United States          Kent     Washington
## 74   Sarah Brown Consumer United States New York City       New York
## 75 William Brown Consumer United States   Los Angeles     California
## 76 William Brown Consumer United States   Los Angeles     California
## 77 William Brown Consumer United States   Los Angeles     California
## 78 William Brown Consumer United States   Los Angeles     California
## 79  Philip Brown Consumer United States       Seattle     Washington
## 80 William Brown Consumer United States     Urbandale           Iowa
## 81    Mick Brown Consumer United States     Roseville     California
## 82   Trudy Brown Consumer United States    Hagerstown       Maryland
## 83   Trudy Brown Consumer United States  Philadelphia   Pennsylvania
## 84 William Brown Consumer United States  Philadelphia   Pennsylvania
## 85 William Brown Consumer United States  Philadelphia   Pennsylvania
##    Postal.Code  Region      Product.ID        Category Sub.Category
## 1        19143    East OFF-AR-10003478 Office Supplies          Art
## 2        85023    West OFF-ST-10000760 Office Supplies      Storage
## 3        10035    East TEC-AC-10004571      Technology  Accessories
## 4        60653 Central FUR-BO-10004218       Furniture    Bookcases
## 5        60653 Central TEC-PH-10002185      Technology       Phones
## 6        90045    West TEC-PH-10001079      Technology       Phones
## 7        90045    West FUR-TA-10002041       Furniture       Tables
## 8        90045    West OFF-BI-10001036 Office Supplies      Binders
## 9        90045    West OFF-PA-10000223 Office Supplies        Paper
## 10       90045    West TEC-MA-10003246      Technology     Machines
## 11       10009    East OFF-LA-10002762 Office Supplies       Labels
## 12       85323    West OFF-SU-10001664 Office Supplies     Supplies
## 13       85323    West TEC-AC-10002550      Technology  Accessories
## 14       94521    West FUR-FU-10003975       Furniture  Furnishings
## 15       33178   South OFF-EN-10001099 Office Supplies    Envelopes
## 16       75051 Central OFF-AP-10001563 Office Supplies   Appliances
## 17       75051 Central TEC-AC-10004510      Technology  Accessories
## 18       90004    West OFF-BI-10003364 Office Supplies      Binders
## 19       90004    West FUR-FU-10001861       Furniture  Furnishings
## 20       90004    West FUR-FU-10004845       Furniture  Furnishings
## 21       60201 Central TEC-CO-10001766      Technology      Copiers
## 22       60201 Central TEC-AC-10004396      Technology  Accessories
## 23       90045    West OFF-LA-10004484 Office Supplies       Labels
## 24       90045    West TEC-MA-10004002      Technology     Machines
## 25       90045    West OFF-ST-10002406 Office Supplies      Storage
## 26       90045    West TEC-PH-10003645      Technology       Phones
## 27        6040    East OFF-ST-10001558 Office Supplies      Storage
## 28        6040    East OFF-ST-10001328 Office Supplies      Storage
## 29       19134    East OFF-EN-10003072 Office Supplies    Envelopes
## 30       97756    West TEC-PH-10000576      Technology       Phones
## 31       97756    West TEC-PH-10004188      Technology       Phones
## 32       97756    West OFF-AP-10001469 Office Supplies   Appliances
## 33        3301    East OFF-BI-10002735 Office Supplies      Binders
## 34       94110    West OFF-AR-10004648 Office Supplies          Art
## 35       94110    West FUR-TA-10001857       Furniture       Tables
## 36       19134    East OFF-BI-10003656 Office Supplies      Binders
## 37       19134    East OFF-FA-10000053 Office Supplies    Fasteners
## 38       19134    East TEC-PH-10002807      Technology       Phones
## 39       75051 Central FUR-FU-10002364       Furniture  Furnishings
## 40       75051 Central OFF-BI-10002954 Office Supplies      Binders
## 41       10011    East OFF-EN-10001137 Office Supplies    Envelopes
## 42       10011    East OFF-PA-10004285 Office Supplies        Paper
## 43       10011    East OFF-BI-10002225 Office Supplies      Binders
## 44        8360    East FUR-TA-10001095       Furniture       Tables
## 45       90004    West FUR-CH-10004886       Furniture       Chairs
## 46       90004    West OFF-PA-10002751 Office Supplies        Paper
## 47       77036 Central TEC-PH-10001552      Technology       Phones
## 48       65807 Central OFF-EN-10003286 Office Supplies    Envelopes
## 49       65807 Central TEC-AC-10000109      Technology  Accessories
## 50       67212 Central TEC-PH-10003171      Technology       Phones
## 51       77571 Central FUR-FU-10004963       Furniture  Furnishings
## 52       77571 Central OFF-BI-10001597 Office Supplies      Binders
## 53       92804    West OFF-BI-10004593 Office Supplies      Binders
## 54       92804    West OFF-AR-10000914 Office Supplies          Art
## 55       92804    West OFF-PA-10000241 Office Supplies        Paper
## 56       92804    West TEC-AC-10000057      Technology  Accessories
## 57       92804    West FUR-CH-10003774       Furniture       Chairs
## 58       92804    West OFF-BI-10002824 Office Supplies      Binders
## 59       92804    West OFF-BI-10004001 Office Supplies      Binders
## 60       92804    West FUR-TA-10004619       Furniture       Tables
## 61       92804    West OFF-ST-10000636 Office Supplies      Storage
## 62       92804    West OFF-AP-10001469 Office Supplies   Appliances
## 63       92804    West OFF-BI-10002897 Office Supplies      Binders
## 64       90049    West OFF-BI-10002103 Office Supplies      Binders
## 65       28205   South OFF-BI-10003982 Office Supplies      Binders
## 66       28205   South TEC-PH-10004977      Technology       Phones
## 67       28205   South OFF-LA-10003510 Office Supplies       Labels
## 68       10009    East OFF-BI-10004519 Office Supplies      Binders
## 69       10009    East TEC-AC-10002167      Technology  Accessories
## 70       10009    East OFF-FA-10000936 Office Supplies    Fasteners
## 71       10009    East FUR-FU-10000732       Furniture  Furnishings
## 72       98031    West TEC-PH-10002564      Technology       Phones
## 73       98031    West OFF-PA-10001639 Office Supplies        Paper
## 74       10024    East FUR-BO-10002213       Furniture    Bookcases
## 75       90049    West OFF-BI-10003091 Office Supplies      Binders
## 76       90049    West OFF-ST-10002974 Office Supplies      Storage
## 77       90049    West OFF-AR-10000255 Office Supplies          Art
## 78       90049    West TEC-AC-10001284      Technology  Accessories
## 79       98115    West FUR-FU-10002759       Furniture  Furnishings
## 80       50322 Central OFF-FA-10004854 Office Supplies    Fasteners
## 81       95661    West FUR-FU-10001196       Furniture  Furnishings
## 82       21740    East OFF-BI-10000050 Office Supplies      Binders
## 83       19134    East FUR-CH-10003981       Furniture       Chairs
## 84       19143    East OFF-BI-10000014 Office Supplies      Binders
## 85       19143    East FUR-FU-10001475       Furniture  Furnishings
##                                                                                                     Product.Name
## 1                                             Avery Hi-Liter EverBold Pen Style Fluorescent Highlighters, 4/Pack
## 2                                                                                 Eldon Fold 'N Roll Cart System
## 3                                                                       Logitech G700s Rechargeable Gaming Mouse
## 4                             Bush Heritage Pine Collection 5-Shelf Bookcase, Albany Pine Finish, *Special Order
## 5                                           QVS USB Car Charger 2-Port 2.1Amp for iPod/iPhone/iPad/iPad 2/iPad 3
## 6                                                                     Polycom SoundPoint Pro SE-225 Corded phone
## 7                                                                       Bevis Round Conference Table Top, X-Base
## 8                                                                               Cardinal EasyOpen D-Ring Binders
## 9                                                                                                     Xerox 2000
## 10                                                                         Hewlett-Packard Deskjet D4360 Printer
## 11                                                                                                     Avery 485
## 12                                                         Acme Office Executive Series Stainless Steel Trimmers
## 13                                                      Memorex 25GB 6X Branded Blu-Ray Recordable Disc, 30/Pack
## 14                                                     Eldon Advantage Chair Mats for Low to Medium Pile Carpets
## 15                                                                                               Staple envelope
## 16                                                      Belkin Premiere Surge Master II 8-outlet surge protector
## 17                                                               Logitech Desktop MK120 Mouse and keyboard Combo
## 18                                                                                      Binding Machine Supplies
## 19                                                    Floodlight Indoor Halogen Bulbs, 1 Bulb per Pack, 60 Watts
## 20                                                                   Deflect-o EconoMat Nonstudded, No Bevel Mat
## 21                                                                                            Canon PC940 Copier
## 22                                                                                        Logitech Keyboard K120
## 23                                                                                                     Avery 476
## 24                                                          Zebra GX420t Direct Thermal/Thermal Transfer Printer
## 25                                                                                      Pizazz Global Quick File
## 26                                                                                         Aastra 57i VoIP phone
## 27                                                                      Acco Perma 4000 Stacking Storage Drawers
## 28                                                                     Personal Filing Tote with Lid, Black/Gray
## 29                                                                                         Peel & Seel Envelopes
## 30                                                                                        AT&T 1080 Corded phone
## 31                                                             OtterBox Commuter Series Case - Samsung Galaxy S4
## 32                                                        Fellowes 8 Outlet Superior Workstation Surge Protector
## 33                                                                              GBC Prestige Therm-A-Bind Covers
## 34                                                            Boston 19500 Mighty Mite Electric Pencil Sharpener
## 35                                                                             Balt Solid Wood Rectangular Table
## 36                                                                   Fellowes PB200 Plastic Comb Binding Machine
## 37                                                                           Revere Boxed Rubber Bands by Revere
## 38                                                                     Motorla HX550 Universal Bluetooth Headset
## 39                                                                  Eldon Expressions Wood Desk Accessories, Oak
## 40                                            Newell 3-Hole Punched Plastic Slotted Magazine Holders for Binders
## 41                                                                      #10 Gummed Flap White Envelopes, 100/Box
## 42                                                                                                    Xerox 1959
## 43                                                  Square Ring Data Binders, Rigid 75 Pt. Covers, 11" x 14-7/8"
## 44                                                                            Chromcraft Round Conference Tables
## 45                                                                                    Bevis Steel Folding Chairs
## 46                                                                                                    Xerox 1920
## 47 I Need's 3d Hello Kitty Hybrid Silicone Case Cover for HTC One X 4g with 3d Hello Kitty Stylus Pen Green/pink
## 48                                                                                               Staple envelope
## 49                                                              Sony Micro Vault Click 16 GB USB 2.0 Flash Drive
## 50                                                             Plantronics Encore H101 Dual Earpieces\xa0Headset
## 51                                                                Eldon 400 Class Desk Accessories, Black Carbon
## 52                                                        Wilson Jones Ledger-Size, Piano-Hinge Binder, 2", Blue
## 53                                                                 Ibico Laser Imprintable Binding System Covers
## 54                                                           Boston 16765 Mini Stand Up Battery Pencil Sharpener
## 55                                                               IBM Multi-Purpose Copy Paper, 8 1/2 x 11", Case
## 56                                                                     Microsoft Natural Ergonomic Keyboard 4000
## 57                                                               Global Wood Trimmed Manager's Task Chair, Khaki
## 58                                                                                   Recycled Easel Ring Binders
## 59                                                                                GBC Recycled VeloBinder Covers
## 60                                                                                Hon Non-Folding Utility Tables
## 61                                                                     Rogers Profile Extra Capacity Storage Tub
## 62                                                        Fellowes 8 Outlet Superior Workstation Surge Protector
## 63                                                          Black Avery Memo-Size 3-Ring Binder, 5 1/2" x 8 1/2"
## 64                                                               Cardinal Slant-D Ring Binder, Heavy Gauge Vinyl
## 65                                                              Wilson Jones Century Plastic Molded Ring Binders
## 66                                                                                                   GE 30524EE4
## 67                             Avery 4027 File Folder Labels for Dot Matrix Printers, 5000 Labels per Box, White
## 68                                                                      GBC DocuBind P100 Manual Binding Machine
## 69                                                       Imation\xa08gb Micro Traveldrive Usb 2.0\xa0Flash Drive
## 70                                                                                    Acco Hot Clips Clips to Go
## 71                                                                              Eldon 200 Class Desk Accessories
## 72                                                             OtterBox Defender Series Case - Samsung Galaxy S4
## 73                                                                                                     Xerox 203
## 74                                                                         DMI Eclipse Executive Suite Bookcases
## 75                                                                     GBC DocuBind TL200 Manual Binding Machine
## 76                                                                      Trav-L-File Heavy-Duty Shuttle II, Black
## 77                                                                                                    Newell 328
## 78                                                          Enermax Briskie RF Wireless Keyboard and Mouse Combo
## 79                                                                              12-1/2 Diameter Round Wall Clock
## 80                                                       Vinyl Coated Wire Paper Clips in Organizer Box, 800/Box
## 81                                                                                     DAX Cubicle Frames - 8x10
## 82                                                             Angle-D Binders with Locking Rings, Label Holders
## 83                                                            Global Commerce Series Low-Back Swivel/Tilt Chairs
## 84                                                                                      Heavy-Duty E-Z-D Binders
## 85                                                                                    Contract Clock, 14", Brown
##       Sales Quantity Discount    Profit
## 1    19.536        3      0.2    4.8840
## 2    55.920        5      0.2    6.2910
## 3   199.980        2      0.0   83.9916
## 4   493.430        5      0.3  -70.4900
## 5    11.120        2      0.2    3.4750
## 6   666.344        7      0.2   66.6344
## 7   573.728        4      0.2  -64.5444
## 8    21.936        3      0.2    8.2260
## 9    19.440        3      0.0    9.3312
## 10  447.968        4      0.2  139.9900
## 11   25.060        2      0.0   11.7782
## 12   47.992        7      0.2    3.5994
## 13  102.240        4      0.2  -16.6140
## 14   43.310        1      0.0    4.3310
## 15   23.472        3      0.2    7.6284
## 16   19.432        2      0.8  -49.5516
## 17   65.440        5      0.2   -8.1800
## 18   70.008        3      0.2   24.5028
## 19   77.600        4      0.0   38.0240
## 20  464.850        9      0.0   92.9700
## 21 1439.968        4      0.2  485.9892
## 22   43.560        3      0.2   -4.9005
## 23    8.260        2      0.0    3.7996
## 24 2973.320        7      0.2  334.4985
## 25  104.790        7      0.0   29.3412
## 26  775.728        6      0.2   58.1796
## 27   16.240        1      0.0    2.4360
## 28   77.550        5      0.0   21.7140
## 29    6.208        2      0.2    2.1728
## 30  438.368        4      0.2   38.3572
## 31  139.944        7      0.2  -31.4874
## 32  133.472        4      0.2   15.0156
## 33   68.620        2      0.0   32.2514
## 34   60.450        3      0.0   16.3215
## 35  253.176        3      0.2  -31.6470
## 36  152.991        3      0.7 -122.3928
## 37   10.584        7      0.2   -2.3814
## 38   94.920        4      0.4   15.8200
## 39   14.760        5      0.6  -11.4390
## 40    3.656        4      0.8   -5.8496
## 41   16.520        4      0.0    7.5992
## 42   60.120        9      0.0   28.8576
## 43   49.536        3      0.2   17.3376
## 44  244.006        2      0.3  -31.3722
## 45  383.800        5      0.2   38.3800
## 46   17.940        3      0.0    8.0730
## 47   19.136        2      0.2    1.9136
## 48   16.560        2      0.0    7.7832
## 49  279.950        5      0.0   67.1880
## 50  224.750        5      0.0   62.9300
## 51   14.000        4      0.6   -6.3000
## 52   16.392        2      0.8  -26.2272
## 53  209.600        5      0.2   68.1200
## 54   23.320        2      0.0    6.0632
## 55   30.980        1      0.0   13.9410
## 56  119.960        4      0.0   25.1916
## 57  363.920        5      0.2  -31.8430
## 58   35.808        3      0.2   11.1900
## 59  122.688        9      0.2   39.8736
## 60  892.136        7      0.2  111.5170
## 61   50.220        3      0.0    2.0088
## 62   83.420        2      0.0   24.1918
## 63    5.872        2      0.2    2.1286
## 64   13.904        2      0.2    4.5188
## 65   68.541       11      0.7  -52.5481
## 66  627.168        4      0.2   70.5564
## 67  122.120        5      0.2   39.6890
## 68  663.920        5      0.2  207.4750
## 69  120.000        8      0.0   13.2000
## 70    3.290        1      0.0    1.4805
## 71   18.840        3      0.0    6.0288
## 72   71.976        3      0.2    8.9970
## 73   19.440        3      0.0    9.3312
## 74  400.784        1      0.2   -5.0098
## 75  895.920        5      0.2  302.3730
## 76  130.710        3      0.0   39.2130
## 77   11.680        2      0.0    3.0368
## 78   62.310        3      0.0   22.4316
## 79  199.800       10      0.0   71.9280
## 80   45.920        4      0.0   21.5824
## 81   17.310        3      0.0    5.1930
## 82   43.800        6      0.0   20.5860
## 83 1079.316        6      0.3  -15.4188
## 84    3.273        1      0.7   -2.5093
## 85   87.920        5      0.2   15.3860
# Filtro por coincidencia

2.2.9 interval()

# Calcular las ventas del Guadalupe-Reyes
df %>%
  filter(Order.Date %within% interval(ymd("2016/12/12"), ymd("2017/01/06"))) %>%
  head(.)
##   Row.ID       Order.ID Order.Date  Ship.Date      Ship.Mode Customer.ID
## 1   4035 US-2016-108777 2016-12-12 2016-12-12       Same Day    JM-15655
## 2   4036 US-2016-108777 2016-12-12 2016-12-12       Same Day    JM-15655
## 3   4574 CA-2016-139395 2016-12-12 2016-12-18 Standard Class    MG-17650
## 4   4575 CA-2016-139395 2016-12-12 2016-12-18 Standard Class    MG-17650
## 5   4576 CA-2016-139395 2016-12-12 2016-12-18 Standard Class    MG-17650
## 6   4577 CA-2016-139395 2016-12-12 2016-12-18 Standard Class    MG-17650
##       Customer.Name     Segment       Country    City    State Postal.Code
## 1       Jim Mitchum   Corporate United States  Lorain     Ohio       44052
## 2       Jim Mitchum   Corporate United States  Lorain     Ohio       44052
## 3 Matthew Grinstein Home Office United States Jackson Michigan       49201
## 4 Matthew Grinstein Home Office United States Jackson Michigan       49201
## 5 Matthew Grinstein Home Office United States Jackson Michigan       49201
## 6 Matthew Grinstein Home Office United States Jackson Michigan       49201
##    Region      Product.ID        Category Sub.Category
## 1    East OFF-BI-10003982 Office Supplies      Binders
## 2    East TEC-AC-10002567      Technology  Accessories
## 3 Central TEC-PH-10002103      Technology       Phones
## 4 Central FUR-FU-10003724       Furniture  Furnishings
## 5 Central OFF-AR-10003732 Office Supplies          Art
## 6 Central OFF-ST-10000885 Office Supplies      Storage
##                                       Product.Name   Sales Quantity Discount
## 1 Wilson Jones Century Plastic Molded Ring Binders  18.693        3      0.7
## 2              Logitech G602 Wireless Gaming Mouse 383.952        6      0.2
## 3                                  Jabra SPEAK 410 657.930        7      0.0
## 4             Westinghouse Clip-On Gooseneck Lamps  33.480        4      0.0
## 5                                       Newell 333  13.900        5      0.0
## 6            Fellowes Desktop Hanging File Manager  26.860        2      0.0
##     Profit
## 1 -14.3313
## 2  76.7904
## 3 184.2204
## 4   8.7048
## 5   3.6140
## 6   6.7150

2.2.10 is.na

sapply(df, function(x) sum(is.na(x)))
##        Row.ID      Order.ID    Order.Date     Ship.Date     Ship.Mode 
##             0             0             0             0             0 
##   Customer.ID Customer.Name       Segment       Country          City 
##             0             0             0             0             0 
##         State   Postal.Code        Region    Product.ID      Category 
##             0             0             0             0             0 
##  Sub.Category  Product.Name         Sales      Quantity      Discount 
##             0             0             0             0             0 
##        Profit 
##             0

2.2.11 summarise

# Presenta una tabla de resumen 
df %>%
  group_by(day(Order.Date)) %>%
  summarise(Q.Sales = sum(Quantity), # Suma de cantidades vendidas 
            Pct.Sales = sum(Quantity)/n(), # Porcentaje de ventas
            Op.Sales = n())  # Conteo de ventas
## # A tibble: 31 × 4
##    `day(Order.Date)` Q.Sales Pct.Sales Op.Sales
##                <int>   <int>     <dbl>    <int>
##  1                 1    1329      3.94      337
##  2                 2    1486      3.92      379
##  3                 3    1355      3.71      365
##  4                 4    1068      3.47      308
##  5                 5    1386      3.79      366
##  6                 6    1071      3.76      285
##  7                 7    1102      3.70      298
##  8                 8    1372      3.85      356
##  9                 9    1272      3.70      344
## 10                10    1117      3.72      300
## # ℹ 21 more rows

2.2.12 weekday

df %>%
  mutate(weekday = wday(Order.Date, label = TRUE)) %>% # Extrae el día de la semana y lo convierte a un factor con etiquetas
  group_by(weekday) %>% # Agrupa por día de la semana
  summarise(Q.Sales = sum(Quantity), # Suma total de cantidad vendida
            Pct.Sales = sum(Quantity)/n(), #Porcentaje de ventas
            Op.Sales = n()) # Número de operaciones/ventas
## # A tibble: 7 × 4
##   weekday  Q.Sales Pct.Sales Op.Sales
##   <ord>      <int>     <dbl>    <int>
## 1 "dom\\."    6446      3.77     1710
## 2 "lun\\."    7098      3.79     1871
## 3 "mar\\."    4234      3.83     1106
## 4 "mié\\."    1454      3.92      371
## 5 "jue\\."    5397      3.69     1463
## 6 "vie\\."    6895      3.79     1818
## 7 "sáb\\."    6349      3.84     1655

Análisis de operación por fechas

Por día de la semana

# vamos a extraer el dia de la semana con weekday a partir de Order.Date
df %>%
  select(Order.Date, Quantity, Sales) %>% #Seleccionamos columnas
  mutate(Weekday.Order = wday(Order.Date, label=TRUE)) %>% # extraer día de la semana
  group_by(Weekday.Order)%>% # Agrupar por día de la semana
  summarise(Tot.Sales = sum(Sales), # Ventas totales
            Avg.Sales = mean(Sales), # Ventas promedio
            Tot.Quantity = sum(Quantity), # Cantidad total
            Avg.Quantity = mean(Quantity), # Cantidad promedio
            Orders = n()) %>% # Número de órdenes
mutate(Pct.Quantity=Tot.Quantity*100/sum(Tot.Quantity)) # Cantidad en porcentaje
## # A tibble: 7 × 7
##   Weekday.Order Tot.Sales Avg.Sales Tot.Quantity Avg.Quantity Orders
##   <ord>             <dbl>     <dbl>        <int>        <dbl>  <int>
## 1 "dom\\."        385354.      225.         6446         3.77   1710
## 2 "lun\\."        428938.      229.         7098         3.79   1871
## 3 "mar\\."        287210.      260.         4234         3.83   1106
## 4 "mié\\."         88057.      237.         1454         3.92    371
## 5 "jue\\."        321966.      220.         5397         3.69   1463
## 6 "vie\\."        427692.      235.         6895         3.79   1818
## 7 "sáb\\."        357985.      216.         6349         3.84   1655
## # ℹ 1 more variable: Pct.Quantity <dbl>

Por día del mes

df %>%
  select(Order.Date, Quantity, Sales) %>%
  mutate(Day.Order = day(Order.Date)) %>%
  group_by(Day.Order) %>%
  summarise(Tot.Sales = sum(Sales),
            Avg.Sales = mean(Sales),
            Tot.Quantity = sum(Quantity),
            Avg.Quantity = mean(Quantity),
            Orders = n()) %>%
  mutate(Pct.Quantity = Tot.Quantity*100/sum(Tot.Quantity))
## # A tibble: 31 × 7
##    Day.Order Tot.Sales Avg.Sales Tot.Quantity Avg.Quantity Orders Pct.Quantity
##        <int>     <dbl>     <dbl>        <int>        <dbl>  <int>        <dbl>
##  1         1    95525.      283.         1329         3.94    337         3.51
##  2         2   105139.      277.         1486         3.92    379         3.92
##  3         3    72320.      198.         1355         3.71    365         3.58
##  4         4    68162.      221.         1068         3.47    308         2.82
##  5         5    64521.      176.         1386         3.79    366         3.66
##  6         6    53307.      187.         1071         3.76    285         2.83
##  7         7    62611.      210.         1102         3.70    298         2.91
##  8         8   101578.      285.         1372         3.85    356         3.62
##  9         9    66582.      194.         1272         3.70    344         3.36
## 10        10    62994.      210.         1117         3.72    300         2.95
## # ℹ 21 more rows

Por semana del año

df %>%
  select(Order.Date, Sales, Quantity) %>%
  mutate(Week.Order = week(Order.Date)) %>%
  group_by(Week.Order) %>%
   summarise(Tot.Sales = sum(Sales),
            Avg.Sales = mean(Sales),
            Tot.Quantity = sum(Quantity),
            Avg.Quantity = mean(Quantity),
            Orders = n()) %>%
  mutate(Pct.Quantity = Tot.Quantity*100/sum(Tot.Quantity))
## # A tibble: 53 × 7
##    Week.Order Tot.Sales Avg.Sales Tot.Quantity Avg.Quantity Orders Pct.Quantity
##         <dbl>     <dbl>     <dbl>        <int>        <dbl>  <int>        <dbl>
##  1          1    22081.      263.          339         4.04     84        0.895
##  2          2    17603.      229.          304         3.95     77        0.803
##  3          3    20955.      230.          338         3.71     91        0.892
##  4          4    22740.      292.          321         4.12     78        0.848
##  5          5    25041.      264.          324         3.41     95        0.855
##  6          6    17177.      204.          296         3.52     84        0.782
##  7          7    13319.      162.          283         3.45     82        0.747
##  8          8    10772.      163.          234         3.55     66        0.618
##  9          9    28880.      280.          402         3.90    103        1.06 
## 10         10    30373.      212.          494         3.45    143        1.30 
## # ℹ 43 more rows

Por mes

df%>%
  select(Order.Date, Sales, Quantity) %>%
  mutate(Month.Order = month(Order.Date, label=TRUE)) %>%
  group_by(Month.Order) %>%
  summarise(Tot.Sales = sum(Sales),
            Avg.Sales = mean(Sales),
            Tot.Quantity = sum(Quantity),
            Avg.Quantity = mean(Quantity),
            Orders = n()) %>%
  mutate(Pct.Quantity = Tot.Quantity*100/sum(Tot.Quantity))
## # A tibble: 12 × 7
##    Month.Order Tot.Sales Avg.Sales Tot.Quantity Avg.Quantity Orders Pct.Quantity
##    <ord>           <dbl>     <dbl>        <int>        <dbl>  <int>        <dbl>
##  1 ene            94925.      249.         1475         3.87    381         3.89
##  2 feb            59751.      199.         1067         3.56    300         2.82
##  3 mar           205005.      295.         2564         3.68    696         6.77
##  4 abr           137762.      206.         2447         3.66    668         6.46
##  5 may           155029.      211.         2791         3.80    735         7.37
##  6 jun           152719.      213.         2680         3.74    717         7.08
##  7 jul           147238.      207.         2705         3.81    710         7.14
##  8 ago           159044.      225.         2784         3.94    706         7.35
##  9 sep           307650.      222.         5062         3.66   1383        13.4 
## 10 oct           200323.      245.         3104         3.79    819         8.20
## 11 nov           352461.      240.         5775         3.93   1471        15.2 
## 12 dic           325294.      231.         5419         3.85   1408        14.3

Por año

df%>%
  select(Order.Date, Sales, Quantity) %>%
  mutate(Year.Order = year(Order.Date)) %>%
  group_by(Year.Order) %>%
   summarise(Tot.Sales = sum(Sales),
            Avg.Sales = mean(Sales),
            Tot.Quantity = sum(Quantity),
            Avg.Quantity = mean(Quantity),
            Orders = n()) %>%
  mutate(Pct.Quantity = Tot.Quantity*100/sum(Tot.Quantity)) %>%
  arrange(Year.Order) %>%
    mutate(Grate.Orders = (Orders - lag(Orders))*100/lag(Orders))
## # A tibble: 4 × 8
##   Year.Order Tot.Sales Avg.Sales Tot.Quantity Avg.Quantity Orders Pct.Quantity
##        <dbl>     <dbl>     <dbl>        <int>        <dbl>  <int>        <dbl>
## 1       2014   484247.      243.         7581         3.80   1993         20.0
## 2       2015   470533.      224.         7979         3.80   2102         21.1
## 3       2016   609206.      235.         9837         3.80   2587         26.0
## 4       2017   733215.      221.        12476         3.77   3312         32.9
## # ℹ 1 more variable: Grate.Orders <dbl>