###PARCIAL

library(tidyverse)
library(data.table)
library(lubridate)
library(ggrepel)
library(scales)
library(hrbrthemes)

setwd("C:/Users/Daniela mora/OneDrive/Escritorio/info")
data <- fread("superstore.csv")

aux1 <- data %>% 
  mutate(FecOrden =  as.Date(FecOrden, "%d/%m/%Y"),
         FecEnvio =  as.Date(FecEnvio, "%d/%m/%Y"),
         FechaOrden= floor_date(FecOrden, unit = "month")
  ) %>% 
  group_by(FechaOrden, Segmento, Categoria, Prioridad) %>% 
  summarise(TotVentas = sum(Venta)
  ) 


ggplot(aux1,aes(x=FechaOrden,y=TotVentas,color=Segmento))+
  facet_grid(Categoria~Prioridad)+
  geom_line()+
  geom_smooth(method = "lm")+
  labs(x = "Fecha de Orden", y = "Ventas",
       title = "Historico de ventas")+
  theme_classic()+
  theme_ft_rc()