I have created a function that graphs out the different performance for suppliers. I am looking to save each of these graphs using their supplier number, but I am having problems writing the code for this. Here is what I have so far.
split_supplier <- split(mtdtotalchanges, mtdtotalchanges$supplier)
my_plot <- function(dat) {
ggplot(dat, aes(x = filldate, y = totalfill)) +
geom_col()+
geom_vline(xintercept = "2021-02-15", linetype=8, col = "blue", size = 1) +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
xlab(label= "Fill Month") +
labs(title = unique(dat$supplier))+
ggsave( as.character(unique(dat$supplier))+".jpg")
}
lapply(split_supplier, my_plot)