El presente ejercicio se centra en el análisis de datos transaccionales de una tienda minorista recolectados durante un período específico. La tabla proporcionada incluye información detallada sobre clientes, precios, productos, ganancias, entre otros aspectos relevantes.
knitr::opts_chunk$set(
echo = TRUE,
message = FALSE,
warning = FALSE
)
library(readxl)
Ventas_tienda_minorista <- read_excel("Ventas tienda minorista.xlsx")
library(dplyr)
library(tidyr)
library(lubridate)
library(tidyverse)
library(kableExtra)
library(ggplot2)
ventas_categoria_estado<-Ventas_tienda_minorista %>%
group_by(`Product Category`,`State or Province`) %>%
summarise(Total_Ventas = sum(Sales, na.rm = TRUE)) %>%
arrange(desc(Total_Ventas))
print(ventas_categoria_estado)
## # A tibble: 142 × 3
## # Groups: Product Category [3]
## `Product Category` `State or Province` Total_Ventas
## <chr> <chr> <dbl>
## 1 Furniture California 108541.
## 2 Technology California 98438.
## 3 Technology New York 93818.
## 4 Office Supplies California 81332.
## 5 Furniture New York 72852.
## 6 Office Supplies New York 57260.
## 7 Office Supplies District of Columbia 56752.
## 8 Technology Illinois 48015.
## 9 Furniture Florida 46019.
## 10 Technology Washington 45691.
## # ℹ 132 more rows
kable(head(ventas_categoria_estado))
Product Category | State or Province | Total_Ventas |
---|---|---|
Furniture | California | 108540.94 |
Technology | California | 98438.15 |
Technology | New York | 93818.01 |
Office Supplies | California | 81331.52 |
Furniture | New York | 72852.08 |
Office Supplies | New York | 57260.39 |
Por ejemplo, en la categoria Tecnologia en California se vendieron un total de 98.438$
porcentaje_segmento <-Ventas_tienda_minorista %>%
group_by(`Customer Segment`) %>%
summarise(Total_Ventas = sum(Sales, na.rm = TRUE)) %>%
mutate(Porcentaje = (Total_Ventas / sum(Total_Ventas)) * 100)
print(porcentaje_segmento)
## # A tibble: 4 × 3
## `Customer Segment` Total_Ventas Porcentaje
## <chr> <dbl> <dbl>
## 1 Consumer 401778. 20.9
## 2 Corporate 657785. 34.2
## 3 Home Office 464481. 24.1
## 4 Small Business 400294. 20.8
ggplot(porcentaje_segmento, aes(x = `Customer Segment`, y = Total_Ventas)) +
geom_bar(stat = "identity", fill = "skyblue", color = "black") +
labs(title = "Total de Ventas por Segmento",
x = "Segmento",
y = "Total de Ventas") +
theme_minimal()
El segmento de clientes Home Office tiene un total de ventas de $464.481
lo que representa el 24,1% del total de ventas, ademas se hizo un
grafico de barras para evidenciar las ventas por segmento
promedio_productos <- Ventas_tienda_minorista %>%
summarise(Promedio_Productos = mean(`Quantity ordered new`, na.rm = TRUE))
print(promedio_productos)
## # A tibble: 1 × 1
## Promedio_Productos
## <dbl>
## 1 12.9
En promedio se venden 12,9 unidades por transacción
ggplot(Ventas_tienda_minorista, aes(x = Discount, y = `Product Base Margin`)) +
geom_smooth(method = "loess", color = "blue", fill = "lightblue") +
labs(title = "Relación entre Descuento y Margen de Ganancia",
x = "Descuento",
y = "Margen") +
theme_minimal()
En promedio, mientras mayor es el descuento aplicado, menor es el margen
de ganancia
ganancia_promedio <- Ventas_tienda_minorista %>%
group_by(Region, `Product Category`) %>%
summarise(Promedio_Ganancia = mean(Profit, na.rm = TRUE))
print(ganancia_promedio)
## # A tibble: 12 × 3
## # Groups: Region [4]
## Region `Product Category` Promedio_Ganancia
## <chr> <chr> <dbl>
## 1 Central Furniture 41.8
## 2 Central Office Supplies 89.9
## 3 Central Technology 336.
## 4 East Furniture -4.68
## 5 East Office Supplies 193.
## 6 East Technology 315.
## 7 South Furniture 12.3
## 8 South Office Supplies -8.91
## 9 South Technology -121.
## 10 West Furniture 608.
## 11 West Office Supplies 48.2
## 12 West Technology 78.3
ggplot(ganancia_promedio, aes(x = `Product Category`, y = Promedio_Ganancia, fill = Region)) +
geom_bar(stat = "identity", position = "dodge") +
labs(x = "Producto", y = "Promedio", fill = "Región") +
theme_minimal()
Podemos ver que en el sur la categoria de tecnologia tiene ganancia negativa
ventas_ganancia_cliente <- Ventas_tienda_minorista
total_ventas <- sum(Ventas_tienda_minorista$Sales, na.rm = TRUE)
total_ganancias <- sum(Ventas_tienda_minorista$Profit, na.rm = TRUE)
num_clientes <- n_distinct(Ventas_tienda_minorista$`Customer ID`) # Clientes únicos
ventas_promedio_cliente <- total_ventas / num_clientes
ganancias_promedio_cliente <- total_ganancias / num_clientes
print(ventas_promedio_cliente)
## [1] 1702.954
print(ganancias_promedio_cliente)
## [1] 198.2988
La venta promedio por cliente es de $1702.96 y la ganancia promedio es de $198.30
proporcion_subcategoria <- Ventas_tienda_minorista %>%
group_by(`Product Sub-Category`) %>%
summarise(Cantidad_Total = sum(`Quantity ordered new`, na.rm = TRUE)) %>%
mutate(Proporcion = Cantidad_Total / sum(Cantidad_Total)*100)
print(proporcion_subcategoria)
## # A tibble: 17 × 3
## `Product Sub-Category` Cantidad_Total Proporcion
## <chr> <dbl> <dbl>
## 1 Appliances 1187 4.70
## 2 Binders and Binder Accessories 2554 10.1
## 3 Bookcases 536 2.12
## 4 Chairs & Chairmats 1227 4.86
## 5 Computer Peripherals 2481 9.82
## 6 Copiers and Fax 181 0.716
## 7 Envelopes 590 2.33
## 8 Labels 903 3.57
## 9 Office Furnishings 2356 9.32
## 10 Office Machines 898 3.55
## 11 Paper 3481 13.8
## 12 Pens & Art Supplies 2744 10.9
## 13 Rubber Bands 501 1.98
## 14 Scissors, Rulers and Trimmers 423 1.67
## 15 Storage & Organization 1904 7.54
## 16 Tables 944 3.74
## 17 Telephones and Communication 2358 9.33
ggplot(proporcion_subcategoria, aes(x = reorder(`Product Sub-Category`, Proporcion), y = Proporcion)) +
geom_bar(stat = "identity") +
coord_flip() +
labs(title = "Proporcion de Productos Vendidos por Subcategoria",
x = "Subcategoria",
y = "Proporcion") +
theme_minimal()
La subcategoria mas vendida es papel
ggplot(Ventas_tienda_minorista, aes(x = `Quantity ordered new`, y = Profit, color = Discount)) +
geom_point() +
labs(title = "Relación entre Cantidad Vendida, Margen de Ganancia y Descuento",
x = "Cantidad Vendida",
y = "Margen de Ganancia",
color = "Descuento") +
theme_minimal()
La mayor concentracion de ventas son en torno a las 50 unidades y los descuentos rondan entre 0 y 10% generando ganancia en la mayor parte de los casos
ventas_ganancias_segmento <- Ventas_tienda_minorista %>%
group_by(`Customer Segment`,`Product Sub-Category`) %>%
summarise(Total_Ventas = sum(Sales, na.rm = TRUE),
Total_Ganancia = sum(Profit, na.rm = TRUE))
print(ventas_ganancias_segmento)
## # A tibble: 68 × 4
## # Groups: Customer Segment [4]
## `Customer Segment` `Product Sub-Category` Total_Ventas Total_Ganancia
## <chr> <chr> <dbl> <dbl>
## 1 Consumer Appliances 16151. 985.
## 2 Consumer Binders and Binder Accessories 12559. 3497.
## 3 Consumer Bookcases 28441. 6198.
## 4 Consumer Chairs & Chairmats 90061. 19608.
## 5 Consumer Computer Peripherals 18813. 1041.
## 6 Consumer Copiers and Fax 8926. 1430.
## 7 Consumer Envelopes 2164. 86.6
## 8 Consumer Labels 646. 453.
## 9 Consumer Office Furnishings 15989. 1716.
## 10 Consumer Office Machines 101570. 3280.
## # ℹ 58 more rows
En la categoria de consumidor, la subcategoria de Maquinas de oficina tiene unas ventas de $101.570 y una ganancia promedio de $3280 mientras que la subcategoria etiquetas vende $646 pero tiene una ganancia de $453
ventas_envio <- Ventas_tienda_minorista %>%
group_by(`Ship Mode`) %>%
summarise(Total_Ventas = sum(Sales, na.rm = TRUE))%>%
print
## # A tibble: 3 × 2
## `Ship Mode` Total_Ventas
## <chr> <dbl>
## 1 Delivery Truck 789235.
## 2 Express Air 145050.
## 3 Regular Air 990052.
Las mayor cantidad de ventas se envian por regular aereo, con un monto de $990.052
perfil_subcategoria <- Ventas_tienda_minorista %>%
group_by(`Product Sub-Category`) %>%
summarise(Total_Ganancia = sum(Profit, na.rm = TRUE)) %>%
arrange(desc(Total_Ganancia))
print(perfil_subcategoria)
## # A tibble: 17 × 2
## `Product Sub-Category` Total_Ganancia
## <chr> <dbl>
## 1 Binders and Binder Accessories 59296.
## 2 Chairs & Chairmats 48696.
## 3 Telephones and Communication 40791.
## 4 Copiers and Fax 23990.
## 5 Office Furnishings 18724.
## 6 Appliances 12595.
## 7 Office Machines 8824.
## 8 Paper 7769.
## 9 Storage & Organization 7124.
## 10 Labels 7028.
## 11 Computer Peripherals 1698.
## 12 Pens & Art Supplies -258.
## 13 Bookcases -930.
## 14 Envelopes -1194.
## 15 Scissors, Rulers and Trimmers -1291.
## 16 Rubber Bands -1545.
## 17 Tables -7240.
La subcategoria con mayor ganancia es la de Carpetas y accesorios con $59.296