I have a code in R to perform classification and estimation( using regression modeling) on 60 data sets using random forest algorithm and at the end of it there is a plot to show how a quantity evolves with time. I am performing leave one out procedure on the same and since it takes a long time, I have used parallel processing using the doSnow package. I am able to see that the code does work properly (I am storing the output of my cat commands in a separate log file). However, when I open the plot saved after each iteration of the foreach loop, it is empty. Seems like a complete waste of time since the plot results were the only output that I was saving. What am I doing wrong here? I am using R-Studio.
The code is :
# Plotting
graphics.off()
plotIt(times,result)
dev.copy(device=png,filename=str_c(p1,"/",cur,".png"),width = 800, height = 600)
dev.off()
and the definition for the plotIt
(userdefined fn) is:
plotIt = function(times,result)
{
par(mar=c(4.1,4.2,0.5,0.5))
par(mfrow=c(2,1))
t = time[ length(time) ]
plot(time/60,result
,xlab="time (min)"
,ylab="output"
,xlim=c(min(times)/60,max(times)/60)
,ylim=c(0,1)
,"s"
)
points(t/60,result[length(result)],col="red")
lines(c(min(times)/60,max(times)/60),c(0.5,0.5),lty=2)
lines(c(0,0),c(0,1),lty=3)
}
The plot grows with increasing value of time. As it grows, I am saving each frame. "cur" represents the frame number. Assume my t value goes from 1 to 50, I will have 50 frames with the final frame showing the finished plot. So inside my path(p1) I will have 50 plots (png files).