#Análise Estatística de Dados e Visualização

library(readr)
library(readxl) 
library(writexl)
library(openxlsx)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
library(knitr)
library(forecast)
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo

Introdução

Este relatório apresenta uma análise exploratória e estatística das vendas da empresa, utilizando os dados fornecidos no arquivo Vendas2024.xlsx. A análise utiliza dplyr e ggplot2, como solicitado no projeto, e apresenta estatísticas descritivas, tabelas e visualizações.

Leitura dos dados

# Lendo o mesmo arquivo no computador - neste caso, utilizei o endereço da internet para baixar o arquivo

Vendas2024 <- read_excel("Vendas2024.xlsx")
vendas <- read_excel("Vendas2024.xlsx", sheet = 1)
vendas <- vendas |>
mutate(
vendedor = as.factor(vendedor),
dias = as.Date(dias),
venda_diaria = as.numeric(venda_diaria),
mes = as.numeric(mes),
ano = as.numeric(ano)
)
# Ajuste o caminho se necessário

vendas <- read_excel("Vendas2024.xlsx", sheet = 1)

# Ajuste de tipos

vendas <- vendas |>
mutate(
vendedor = as.factor(vendedor),
dias = as.Date(dias),
venda_diaria = as.numeric(venda_diaria),
mes = as.numeric(mes),
ano = as.numeric(ano)
)

# Remover NAs em venda_diaria

vendas <- vendas |> filter(!is.na(venda_diaria))

# Estrutura

str(vendas)
## tibble [113,202 × 5] (S3: tbl_df/tbl/data.frame)
##  $ vendedor    : Factor w/ 12 levels "101101","101102",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ dias        : Date[1:113202], format: "2018-01-01" "2018-01-01" ...
##  $ venda_diaria: num [1:113202] 372 139 354 241 123 ...
##  $ ano         : num [1:113202] 2018 2018 2018 2018 2018 ...
##  $ mes         : num [1:113202] 1 1 1 1 1 1 1 1 1 1 ...
# 5 primeiras linhas

head(vendas)
## # A tibble: 6 × 5
##   vendedor dias       venda_diaria   ano   mes
##   <fct>    <date>            <dbl> <dbl> <dbl>
## 1 101101   2018-01-01         372.  2018     1
## 2 101101   2018-01-01         139.  2018     1
## 3 101101   2018-01-01         354.  2018     1
## 4 101101   2018-01-01         241.  2018     1
## 5 101101   2018-01-01         123.  2018     1
## 6 101101   2018-01-01         165.  2018     1
# Resumo

summary(vendas)
##     vendedor          dias             venda_diaria         ano      
##  101102 :14604   Min.   :2018-01-01   Min.   :  9.79   Min.   :2018  
##  101101 :13742   1st Qu.:2020-09-19   1st Qu.:133.27   1st Qu.:2020  
##  101103 :12779   Median :2022-02-03   Median :254.06   Median :2022  
##  101104 :10493   Mean   :2021-11-21   Mean   :260.38   Mean   :2021  
##  101105 :10419   3rd Qu.:2023-03-15   3rd Qu.:373.85   3rd Qu.:2023  
##  101106 : 9997   Max.   :2024-03-30   Max.   :838.42   Max.   :2024  
##  (Other):41168                                                       
##       mes        
##  Min.   : 1.000  
##  1st Qu.: 3.000  
##  Median : 7.000  
##  Mean   : 6.548  
##  3rd Qu.:10.000  
##  Max.   :12.000  
## 

Análise Estatística com dplyr

##Estatísticas por vendedor

estat_vendedor <- vendas |>
group_by(vendedor) |>
summarise(
total_vendas = sum(venda_diaria),
media_diaria = mean(venda_diaria),
mediana_diaria = median(venda_diaria),
desvio_padrao = sd(venda_diaria),
registros = n()
) |>
arrange(desc(total_vendas))

kable(estat_vendedor, caption = "Estatísticas por Vendedor")
Estatísticas por Vendedor
vendedor total_vendas media_diaria mediana_diaria desvio_padrao registros
101102 4031176 276.0323 268.370 160.7581 14604
101101 3489519 253.9309 249.280 146.2669 13742
101103 3433923 268.7161 264.700 155.3434 12779
101105 2694622 258.6258 250.790 150.1411 10419
101104 2491491 237.4432 232.130 137.8471 10493
101108 2473665 271.4734 265.235 157.0374 9112
101106 2458056 245.8794 240.990 143.1502 9997
102111 2441308 244.6691 240.990 140.9007 9978
101107 2201441 250.2775 243.280 146.5876 8796
102112 1338667 289.5042 282.730 166.8494 4624
101109 1296194 304.0569 297.620 173.8729 4263
101110 1125154 256.0078 252.310 145.7166 4395

##Venda mensal total (geral)

venda_mensal_geral <- vendas |>
group_by(ano, mes) |>
summarise(total_mensal = sum(venda_diaria))
## `summarise()` has grouped output by 'ano'. You can override using the `.groups`
## argument.
kable(venda_mensal_geral, caption = "Venda Mensal Total da Empresa")
Venda Mensal Total da Empresa
ano mes total_mensal
2018 1 101567.93
2018 2 84566.85
2018 3 85530.13
2018 4 98811.06
2018 5 120225.68
2018 6 97619.83
2018 7 83419.18
2018 8 124339.31
2018 9 120982.09
2018 10 127807.90
2018 11 155285.26
2018 12 187369.81
2019 1 136127.00
2019 2 98931.27
2019 3 114280.20
2019 4 126960.42
2019 5 171233.06
2019 6 149914.75
2019 7 107252.77
2019 8 141441.62
2019 9 129484.14
2019 10 288625.81
2019 11 355359.75
2019 12 468261.28
2020 1 271472.65
2020 2 222533.09
2020 3 382382.08
2020 4 421068.32
2020 5 517596.70
2020 6 416373.11
2020 7 351208.06
2020 8 331284.75
2020 9 400772.74
2020 10 387258.35
2020 11 505659.62
2020 12 595835.98
2021 1 360726.31
2021 2 301422.03
2021 3 385502.04
2021 4 430170.60
2021 5 483334.28
2021 6 476022.42
2021 7 400116.30
2021 8 392945.07
2021 9 375571.56
2021 10 441425.94
2021 11 503923.84
2021 12 608599.31
2022 1 398929.02
2022 2 344108.08
2022 3 366832.24
2022 4 479610.28
2022 5 669782.26
2022 6 616457.44
2022 7 540985.75
2022 8 530524.87
2022 9 510590.58
2022 10 614907.36
2022 11 736200.89
2022 12 817665.03
2023 1 568067.46
2023 2 477297.07
2023 3 577768.37
2023 4 608208.92
2023 5 699119.04
2023 6 682889.59
2023 7 574676.55
2023 8 571171.72
2023 9 572114.63
2023 10 651203.73
2023 11 757312.16
2023 12 898480.62
2024 1 549534.22
2024 2 468779.94
2024 3 553397.54

##Venda mensal por vendedor

venda_mensal_vendedor <- vendas |>
group_by(vendedor, ano, mes) |>
summarise(total_mensal = sum(venda_diaria))
## `summarise()` has grouped output by 'vendedor', 'ano'. You can override using
## the `.groups` argument.
kable(venda_mensal_vendedor, caption = "Venda Mensal por Vendedor")
Venda Mensal por Vendedor
vendedor ano mes total_mensal
101101 2018 1 40681.80
101101 2018 2 41947.67
101101 2018 3 39753.13
101101 2018 4 40270.40
101101 2018 5 60735.17
101101 2018 6 37626.92
101101 2018 7 52441.26
101101 2018 8 34252.90
101101 2018 9 30023.94
101101 2018 10 41341.30
101101 2018 11 51040.47
101101 2018 12 39680.91
101101 2019 1 41224.85
101101 2019 2 29976.22
101101 2019 3 39335.37
101101 2019 4 45675.40
101101 2019 5 62870.07
101101 2019 6 42763.94
101101 2019 7 22912.14
101101 2019 8 33704.01
101101 2019 9 43377.77
101101 2019 10 38542.64
101101 2019 11 45892.56
101101 2019 12 59826.48
101101 2020 1 41723.03
101101 2020 2 40801.88
101101 2020 3 36346.38
101101 2020 4 57174.21
101101 2020 5 46558.86
101101 2020 6 55376.25
101101 2020 7 31939.62
101101 2020 8 34637.89
101101 2020 9 46056.07
101101 2020 10 41511.59
101101 2020 11 55041.55
101101 2020 12 57423.68
101101 2021 1 47447.76
101101 2021 2 38324.18
101101 2021 3 44383.22
101101 2021 4 53238.65
101101 2021 5 53321.54
101101 2021 6 56447.64
101101 2021 7 55493.95
101101 2021 8 51480.23
101101 2021 9 31795.73
101101 2021 10 45357.13
101101 2021 11 65867.85
101101 2021 12 62318.68
101101 2022 1 44862.95
101101 2022 2 37567.03
101101 2022 3 38841.08
101101 2022 4 71495.72
101101 2022 5 53722.20
101101 2022 6 39531.22
101101 2022 7 48382.74
101101 2022 8 43965.06
101101 2022 9 33527.00
101101 2022 10 56199.89
101101 2022 11 72540.26
101101 2022 12 71716.98
101101 2023 1 45169.53
101101 2023 2 47677.66
101101 2023 3 35270.33
101101 2023 4 44725.80
101101 2023 5 55171.66
101101 2023 6 41878.86
101101 2023 7 33125.65
101101 2023 8 43020.87
101101 2023 9 50643.02
101101 2023 10 49500.21
101101 2023 11 63300.72
101101 2023 12 76105.38
101101 2024 1 43886.63
101101 2024 2 44546.65
101101 2024 3 37178.72
101102 2018 1 60886.13
101102 2018 2 42619.18
101102 2018 3 45777.00
101102 2018 4 58540.66
101102 2018 5 59490.51
101102 2018 6 59992.91
101102 2018 7 30977.92
101102 2018 8 49979.25
101102 2018 9 55287.71
101102 2018 10 42099.44
101102 2018 11 52017.64
101102 2018 12 67636.95
101102 2019 1 48626.39
101102 2019 2 40099.17
101102 2019 3 43901.94
101102 2019 4 40445.01
101102 2019 5 47833.10
101102 2019 6 61289.65
101102 2019 7 47540.56
101102 2019 8 62335.37
101102 2019 9 53614.69
101102 2019 10 61192.03
101102 2019 11 54301.42
101102 2019 12 94872.18
101102 2020 1 38565.85
101102 2020 2 33627.55
101102 2020 3 48784.70
101102 2020 4 53038.01
101102 2020 5 66041.61
101102 2020 6 49906.18
101102 2020 7 50975.88
101102 2020 8 33748.93
101102 2020 9 47629.52
101102 2020 10 42814.18
101102 2020 11 61986.54
101102 2020 12 90890.89
101102 2021 1 60906.04
101102 2021 2 23835.06
101102 2021 3 65606.24
101102 2021 4 45976.78
101102 2021 5 38404.23
101102 2021 6 49060.50
101102 2021 7 38758.11
101102 2021 8 49200.11
101102 2021 9 63058.72
101102 2021 10 56906.38
101102 2021 11 63786.96
101102 2021 12 78153.60
101102 2022 1 55255.92
101102 2022 2 34207.18
101102 2022 3 47499.21
101102 2022 4 62037.36
101102 2022 5 46808.94
101102 2022 6 55693.53
101102 2022 7 67518.71
101102 2022 8 44106.31
101102 2022 9 38518.99
101102 2022 10 49778.25
101102 2022 11 67588.72
101102 2022 12 85524.24
101102 2023 1 46544.32
101102 2023 2 50858.30
101102 2023 3 52274.98
101102 2023 4 56676.20
101102 2023 5 44685.25
101102 2023 6 75753.23
101102 2023 7 54960.13
101102 2023 8 54417.98
101102 2023 9 54924.12
101102 2023 10 75660.18
101102 2023 11 54897.82
101102 2023 12 95026.18
101102 2024 1 47541.22
101102 2024 2 33181.72
101102 2024 3 46217.34
101103 2018 8 40107.16
101103 2018 9 35670.44
101103 2018 10 44367.16
101103 2018 11 52227.15
101103 2018 12 80051.95
101103 2019 1 46275.76
101103 2019 2 28855.88
101103 2019 3 31042.89
101103 2019 4 40840.01
101103 2019 5 60529.89
101103 2019 6 45861.16
101103 2019 7 36800.07
101103 2019 8 45402.24
101103 2019 9 32491.68
101103 2019 10 29469.33
101103 2019 11 57024.57
101103 2019 12 69231.29
101103 2020 1 34040.09
101103 2020 2 34720.06
101103 2020 3 53394.72
101103 2020 4 56202.20
101103 2020 5 61665.25
101103 2020 6 42014.44
101103 2020 7 42022.52
101103 2020 8 45156.58
101103 2020 9 55491.47
101103 2020 10 50256.26
101103 2020 11 56058.54
101103 2020 12 67130.83
101103 2021 1 36376.50
101103 2021 2 33595.41
101103 2021 3 33227.95
101103 2021 4 59818.55
101103 2021 5 58715.66
101103 2021 6 62600.09
101103 2021 7 51214.27
101103 2021 8 53747.81
101103 2021 9 45131.78
101103 2021 10 59707.33
101103 2021 11 56102.67
101103 2021 12 63409.49
101103 2022 1 51045.78
101103 2022 2 34164.39
101103 2022 3 45948.09
101103 2022 4 45476.96
101103 2022 5 53996.74
101103 2022 6 46459.24
101103 2022 7 29727.23
101103 2022 8 45158.18
101103 2022 9 54360.77
101103 2022 10 67618.27
101103 2022 11 63546.87
101103 2022 12 49755.54
101103 2023 1 47465.35
101103 2023 2 49485.80
101103 2023 3 53620.82
101103 2023 4 62219.08
101103 2023 5 55499.90
101103 2023 6 56547.28
101103 2023 7 59279.52
101103 2023 8 60395.88
101103 2023 9 58152.23
101103 2023 10 44951.77
101103 2023 11 92007.39
101103 2023 12 86666.28
101103 2024 1 41747.12
101103 2024 2 46263.66
101103 2024 3 44313.81
101104 2019 10 33794.18
101104 2019 11 49385.73
101104 2019 12 65688.42
101104 2020 1 46715.12
101104 2020 2 29915.38
101104 2020 3 42158.82
101104 2020 4 34877.36
101104 2020 5 57734.07
101104 2020 6 39480.47
101104 2020 7 38777.38
101104 2020 8 30401.98
101104 2020 9 36096.87
101104 2020 10 40318.73
101104 2020 11 56019.02
101104 2020 12 62334.30
101104 2021 1 36774.92
101104 2021 2 25862.77
101104 2021 3 38957.57
101104 2021 4 43709.66
101104 2021 5 46277.30
101104 2021 6 52985.08
101104 2021 7 31522.06
101104 2021 8 37061.10
101104 2021 9 35948.57
101104 2021 10 58349.95
101104 2021 11 63357.07
101104 2021 12 72010.63
101104 2022 1 49932.40
101104 2022 2 27377.62
101104 2022 3 33783.94
101104 2022 4 34471.94
101104 2022 5 68517.78
101104 2022 6 52691.69
101104 2022 7 46350.99
101104 2022 8 37598.99
101104 2022 9 43736.90
101104 2022 10 47450.31
101104 2022 11 54349.11
101104 2022 12 68822.24
101104 2023 1 48155.44
101104 2023 2 31349.82
101104 2023 3 53884.72
101104 2023 4 41858.56
101104 2023 5 57249.61
101104 2023 6 65325.10
101104 2023 7 36866.69
101104 2023 8 39211.38
101104 2023 9 38574.54
101104 2023 10 50925.85
101104 2023 11 68969.34
101104 2023 12 57583.34
101104 2024 1 41084.28
101104 2024 2 40511.71
101104 2024 3 48342.67
101105 2019 10 42449.43
101105 2019 11 65144.64
101105 2019 12 57601.64
101105 2020 1 30683.57
101105 2020 2 28573.11
101105 2020 3 38557.74
101105 2020 4 46891.04
101105 2020 5 54064.64
101105 2020 6 55954.07
101105 2020 7 43596.58
101105 2020 8 39722.83
101105 2020 9 46191.38
101105 2020 10 42497.82
101105 2020 11 55015.43
101105 2020 12 62930.58
101105 2021 1 48910.62
101105 2021 2 32011.15
101105 2021 3 49272.21
101105 2021 4 43871.95
101105 2021 5 59294.86
101105 2021 6 50159.39
101105 2021 7 53520.67
101105 2021 8 52949.18
101105 2021 9 44501.40
101105 2021 10 41925.48
101105 2021 11 46053.34
101105 2021 12 76323.37
101105 2022 1 53802.84
101105 2022 2 41266.12
101105 2022 3 37527.97
101105 2022 4 67326.98
101105 2022 5 38395.01
101105 2022 6 51755.83
101105 2022 7 47463.86
101105 2022 8 29691.43
101105 2022 9 50389.50
101105 2022 10 42623.25
101105 2022 11 60050.65
101105 2022 12 65712.66
101105 2023 1 54674.38
101105 2023 2 40549.65
101105 2023 3 50381.04
101105 2023 4 59397.07
101105 2023 5 58379.51
101105 2023 6 53443.95
101105 2023 7 53699.36
101105 2023 8 56296.74
101105 2023 9 41755.10
101105 2023 10 49514.58
101105 2023 11 55557.79
101105 2023 12 76852.62
101105 2024 1 55530.18
101105 2024 2 38729.36
101105 2024 3 55186.72
101106 2019 10 37548.02
101106 2019 11 49206.99
101106 2019 12 70671.43
101106 2020 1 42163.70
101106 2020 2 28291.89
101106 2020 3 44241.16
101106 2020 4 38296.63
101106 2020 5 52844.38
101106 2020 6 38589.21
101106 2020 7 29265.36
101106 2020 8 38487.96
101106 2020 9 42207.37
101106 2020 10 37963.25
101106 2020 11 59080.63
101106 2020 12 75311.16
101106 2021 1 30655.78
101106 2021 2 38480.01
101106 2021 3 39078.94
101106 2021 4 39281.75
101106 2021 5 54357.39
101106 2021 6 41095.05
101106 2021 7 33558.33
101106 2021 8 36138.42
101106 2021 9 35000.16
101106 2021 10 38592.88
101106 2021 11 49079.87
101106 2021 12 46704.00
101106 2022 1 38842.32
101106 2022 2 49873.47
101106 2022 3 32980.65
101106 2022 4 55487.60
101106 2022 5 60911.80
101106 2022 6 43988.99
101106 2022 7 33318.68
101106 2022 8 44194.64
101106 2022 9 52064.92
101106 2022 10 53858.19
101106 2022 11 64545.39
101106 2022 12 53160.32
101106 2023 1 40549.52
101106 2023 2 25910.63
101106 2023 3 52192.52
101106 2023 4 54543.35
101106 2023 5 80185.63
101106 2023 6 54460.64
101106 2023 7 42205.96
101106 2023 8 45039.40
101106 2023 9 48898.60
101106 2023 10 35861.74
101106 2023 11 48334.42
101106 2023 12 54848.14
101106 2024 1 38536.49
101106 2024 2 43693.53
101106 2024 3 43376.99
101107 2020 3 37411.23
101107 2020 4 56681.90
101107 2020 5 57528.10
101107 2020 6 47267.98
101107 2020 7 39980.54
101107 2020 8 42331.26
101107 2020 9 33294.96
101107 2020 10 50274.04
101107 2020 11 48352.69
101107 2020 12 51632.93
101107 2021 1 31529.34
101107 2021 2 38842.04
101107 2021 3 30994.21
101107 2021 4 46837.09
101107 2021 5 59902.15
101107 2021 6 56710.53
101107 2021 7 45639.08
101107 2021 8 37714.43
101107 2021 9 18645.64
101107 2021 10 52331.33
101107 2021 11 39344.72
101107 2021 12 71135.85
101107 2022 1 30047.33
101107 2022 2 48633.94
101107 2022 3 40480.66
101107 2022 4 36265.17
101107 2022 5 47390.38
101107 2022 6 39575.81
101107 2022 7 38074.92
101107 2022 8 53896.20
101107 2022 9 47856.28
101107 2022 10 38500.05
101107 2022 11 36167.03
101107 2022 12 64409.32
101107 2023 1 33212.71
101107 2023 2 33408.24
101107 2023 3 46666.91
101107 2023 4 47119.40
101107 2023 5 51355.69
101107 2023 6 49539.90
101107 2023 7 36181.39
101107 2023 8 40788.21
101107 2023 9 54367.96
101107 2023 10 48918.53
101107 2023 11 66891.38
101107 2023 12 62666.69
101107 2024 1 37202.57
101107 2024 2 27816.98
101107 2024 3 49625.06
101108 2020 3 40287.20
101108 2020 4 39834.30
101108 2020 5 59674.79
101108 2020 6 55556.24
101108 2020 7 42364.64
101108 2020 8 44083.46
101108 2020 9 52584.44
101108 2020 10 43293.87
101108 2020 11 61969.09
101108 2020 12 68630.77
101108 2021 1 34525.65
101108 2021 2 37742.07
101108 2021 3 48854.68
101108 2021 4 53487.21
101108 2021 5 50197.82
101108 2021 6 56985.85
101108 2021 7 45505.89
101108 2021 8 38917.57
101108 2021 9 56213.38
101108 2021 10 47959.59
101108 2021 11 63126.13
101108 2021 12 82214.15
101108 2022 1 34230.79
101108 2022 2 41191.62
101108 2022 3 58873.65
101108 2022 4 67481.57
101108 2022 5 76864.17
101108 2022 6 37195.79
101108 2022 7 51102.40
101108 2022 8 50987.90
101108 2022 9 39343.09
101108 2022 10 42726.22
101108 2022 11 59484.86
101108 2022 12 60823.14
101108 2023 1 39263.91
101108 2023 2 31232.69
101108 2023 3 39938.08
101108 2023 4 42656.60
101108 2023 5 70100.10
101108 2023 6 62499.65
101108 2023 7 52787.92
101108 2023 8 35130.81
101108 2023 9 46627.42
101108 2023 10 59917.05
101108 2023 11 56113.58
101108 2023 12 82224.56
101108 2024 1 36358.63
101108 2024 2 37009.96
101108 2024 3 37490.39
101109 2022 5 39008.32
101109 2022 6 58234.50
101109 2022 7 36848.68
101109 2022 8 51849.04
101109 2022 9 29144.07
101109 2022 10 52264.97
101109 2022 11 74003.36
101109 2022 12 67959.96
101109 2023 1 69639.75
101109 2023 2 55192.42
101109 2023 3 52421.49
101109 2023 4 56328.50
101109 2023 5 57419.20
101109 2023 6 75135.38
101109 2023 7 57240.51
101109 2023 8 49776.84
101109 2023 9 50912.83
101109 2023 10 79406.41
101109 2023 11 71912.10
101109 2023 12 83162.48
101109 2024 1 60652.90
101109 2024 2 33987.64
101109 2024 3 33693.06
101110 2022 5 45843.15
101110 2022 6 61213.07
101110 2022 7 47587.43
101110 2022 8 49755.38
101110 2022 9 38668.54
101110 2022 10 51085.62
101110 2022 11 50252.76
101110 2022 12 54660.01
101110 2023 1 42327.50
101110 2023 2 33983.23
101110 2023 3 36725.08
101110 2023 4 49210.58
101110 2023 5 57250.94
101110 2023 6 50591.92
101110 2023 7 50021.23
101110 2023 8 45758.96
101110 2023 9 43033.40
101110 2023 10 52427.85
101110 2023 11 70183.22
101110 2023 12 55249.31
101110 2024 1 59893.54
101110 2024 2 37693.37
101110 2024 3 41738.19
102111 2019 10 45630.18
102111 2019 11 34403.84
102111 2019 12 50369.84
102111 2020 1 37581.29
102111 2020 2 26603.22
102111 2020 3 41200.13
102111 2020 4 38072.67
102111 2020 5 61485.00
102111 2020 6 32228.27
102111 2020 7 32285.54
102111 2020 8 22713.86
102111 2020 9 41220.66
102111 2020 10 38328.61
102111 2020 11 52136.13
102111 2020 12 59550.84
102111 2021 1 33599.70
102111 2021 2 32729.34
102111 2021 3 35127.02
102111 2021 4 43948.96
102111 2021 5 62863.33
102111 2021 6 49978.29
102111 2021 7 44903.94
102111 2021 8 35736.22
102111 2021 9 45276.18
102111 2021 10 40295.87
102111 2021 11 57205.23
102111 2021 12 56329.54
102111 2022 1 40908.69
102111 2022 2 29826.71
102111 2022 3 30896.99
102111 2022 4 39566.98
102111 2022 5 63356.50
102111 2022 6 62146.51
102111 2022 7 43699.03
102111 2022 8 27354.80
102111 2022 9 37341.67
102111 2022 10 51251.84
102111 2022 11 54907.09
102111 2022 12 77431.22
102111 2023 1 50018.82
102111 2023 2 34667.70
102111 2023 3 47380.27
102111 2023 4 33408.09
102111 2023 5 49778.63
102111 2023 6 51324.63
102111 2023 7 45631.93
102111 2023 8 42452.77
102111 2023 9 39394.53
102111 2023 10 48633.20
102111 2023 11 63571.54
102111 2023 12 84882.05
102111 2024 1 52158.11
102111 2024 2 36653.85
102111 2024 3 50860.12
102112 2022 5 74967.27
102112 2022 6 67971.26
102112 2022 7 50911.08
102112 2022 8 51966.94
102112 2022 9 45638.85
102112 2022 10 61550.50
102112 2022 11 78764.79
102112 2022 12 97689.40
102112 2023 1 51046.23
102112 2023 2 42980.93
102112 2023 3 57012.13
102112 2023 4 60065.69
102112 2023 5 62042.92
102112 2023 6 46389.05
102112 2023 7 52676.26
102112 2023 8 58881.88
102112 2023 9 44830.88
102112 2023 10 55486.36
102112 2023 11 45572.86
102112 2023 12 83213.59
102112 2024 1 34942.55
102112 2024 2 48691.51
102112 2024 3 65374.47

#Visualização de Dados com ggplot2 ##Gráfico de barras: venda total por vendedor

ggplot(estat_vendedor, aes(x = vendedor, y = total_vendas)) +
geom_col() +
labs(title = "Total de Vendas por Vendedor", x = "Vendedor", y = "Total de Vendas")

##Gráfico de linhas: vendas mensais totais da empresa

ggplot(venda_mensal_geral, aes(x = mes, y = total_mensal, group = ano, color = as.factor(ano))) +
geom_line(size = 1) +
labs(title = "Tendência Mensal das Vendas", x = "Mês", y = "Total Mensal")
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

##Gráfico facetado: venda mensal por vendedor

ggplot(venda_mensal_vendedor, aes(x = mes, y = total_mensal, group = vendedor)) +
geom_line() +
facet_wrap(~ vendedor, scales = "free_y") +
labs(title = "Vendas Mensais por Vendedor", x = "Mês", y = "Total Mensal")

##Histograma da venda diária

ggplot(vendas, aes(x = venda_diaria)) +
geom_histogram(bins = 20) +
labs(title = "Distribuição das Vendas Diárias", x = "Venda Diária")

##Boxplot das vendas por mês

ggplot(vendas, aes(x = as.factor(mes), y = venda_diaria)) +
geom_boxplot() +
labs(title = "Vendas Diárias por Mês", x = "Mês", y = "Venda Diária")

##Boxplot das vendas por vendedor

ggplot(vendas, aes(x = vendedor, y = venda_diaria)) +
geom_boxplot() +
labs(title = "Distribuição das Vendas por Vendedor", x = "Vendedor", y = "Venda Diária")

#DESAFIO — Previsão de Vendas

# Série temporal mensal geral

ts_vendas <- ts(venda_mensal_geral$total_mensal, frequency = 12)

modelo <- auto.arima(ts_vendas)

previsao <- forecast(modelo, h = 6)

autoplot(previsao) +
labs(title = "Previsão de Vendas para os Próximos 6 Meses")

#Conclusão

A análise permitiu identificar padrões de vendas, desempenho dos vendedores, tendências mensais e distribuição dos valores diários. Os gráficos facilitam a visualização das variações ao longo do tempo, e o modelo ARIMA fornece uma estimativa da tendência futura da empresa.