I have the following loop:
for(planingPeriod in planingPeriods){
png(paste(planingPeriod,".png",sep=""), width = 30, height = 2, units = 'in', res = 500)
ggplot(data=datasetA, aes(x=as.factor(variable),y=count,fill = value)) +
geom_bar(position = "stack", stat = "identity", width = 1) +
scale_fill_manual(values=c("#4ceb34","#ebd034","#eb34dc","#34ebc3","#3452eb","#eb3434"))
dev.off()
}
It should export plots automatically. My problem is that the files are created but they do not contain any data (white pics without ANY content). I do not get any Warning/Error. When I execute the code without the for loop then a plot is created. What I am doing wrong?