library(tidyverse)
library(openxlsx)
wb.df1 <- loadWorkbook(file = "./data/crackers.xlsx")
crackers.df <- read.xlsx(xlsxFile=wb.df1,sheet="crackers")

sp <- ggplot(data=crackers.df,aes(x=x.pre,y=y.post))
sp + 
  geom_point(shape=16,size=3,aes(color=promotion)) +
  theme_classic() +
  theme(text = element_text(size = 12, colour="black"),
        axis.line = element_line(
          arrow = arrow(type="closed",length = unit(8,'pt')))) + 
  scale_x_continuous(limits = c(15,36)) +
  scale_y_continuous(limits = c(20,46),breaks=seq(20,45,5)) +
  labs(x="\nCracker boxes sold before promotion\n",
       y="\nCracker boxes sold during promotion\n",
       color="Promo") +
  scale_color_manual(values = c("blue","red","purple"))

insertPlot(wb = wb.df1, sheet="crackers",
           fileType = "png", startRow=2, startCol=5)
saveWorkbook(wb=wb.df1, "scatterplot.xlsx",
             overwrite = TRUE)
