[ tutorial] (https://rpubs.com/antoniol/1250655)

VENDAS MENSAL

CARREGANDO OS PACOTES

library(fpp3)

library(quantmod)

library(readr)

library(readxl)

library(writexl)

library(openxlsx)

library(dplyr)

library(lubridate)

library(ggplot2)

library(forecast)

library(fpp)

library(fpp2)

library(tseries)

library(patchwork)

library(mFilter)

library(xts)

library(zoo)

LER OS ARQUIVOS DAS PANILHAS DO EXCEL

Vendas2024 <- read_excel("C:/Users/USUARIO/OneDrive/Desktop/algoritmo/Vendas2024.xlsx")
View(Vendas2024)


vendas <- read_excel("C:/Users/USUARIO/OneDrive/Desktop/algoritmo/Vendas2024.xlsx")

venda_mes <- vendas  %>%
  group_by(ano ,mes) %>%
  summarise(venda_mensal = sum(venda_diaria)) %>%
  arrange(ano, mes)
## `summarise()` has grouped output by 'ano'. You can override using the `.groups`
## argument.

CRIANDO OS GRÁFICOS

DE LINHA

plot(venda_mes$venda_mensal)

SÉRIE TEMPORAL

vendas_mes_ts <- ts(venda_mes$venda_mensal, start = c(2018,1), frequency = 12)
plot(vendas_mes_ts)

TENDÊNCIA, ESTACIONALIDADE E RESIDUOS

decomp_vendas_mes <- decompose(vendas_mes_ts, type = 'additive')
plot(decomp_vendas_mes)

PREVISÃO PARA CADA PERIODO

forecast(vendas_mes_ts , 6, 90)
##          Point Forecast    Lo 90    Hi 90
## Apr 2024       592128.1 508364.8 675891.4
## May 2024       677756.0 563531.7 791980.3
## Jun 2024       626941.9 488818.4 765065.3
## Jul 2024       546903.3 388445.2 705361.4
## Aug 2024       546792.1 370327.1 723257.0
## Sep 2024       543842.9 351045.7 736640.1