I am making ggplots using for loop function and wanted to save all the plots in a file for using in ppt format.
The code I am using is
for(i in 1:28) {
plot_i <- ggplot(Num, aes(Num[,i]))+ geom_histogram(fill="skyblue", col="Blue")+
ggtitle(names(Num)[i])+theme_classic()
ggplot2::ggsave(filename = paste0("plot_",i,".png"),plot_i, path = "E:/Folder1")
}
However when i open the saved png file only 1 out of all 28 graphs is visible When i check if the graphs are actually made or not all the graphs are being made in r studio
for(i in 1:28) {
print(ggplot(Num, aes(Num[,i]))+ geom_histogram(fill="skyblue", col="Blue")+
ggtitle(names(Num)[i]))+theme_classic()
}
This codes helps me in viewing all the plots, but if i have to save it i have to go one by one which is very lengthy process. it will be useful for me if i could save the plots in .doc or .ppt file I have checked similar questions here but the solutions given are not working.