I’m running some some functions in R that sometimes take quite a long time to complete (anywhere from 10 minutes to 4 hours). Specifically, I am using a function (forward.lmer()) written by Rense Nieuwenhuis that can be found here. I’d like to know if there is any way for R to tell the % complete the operation is. Especially, when the operation has been running for over an hour, I’d like to know how close it is to completion.
Is there a generic function that will allow me to know the progress of any given function?
What I would ideally like to know is if there is a function like so:
percentComplete()
forward.lmer(inputs)
That will then tell me about how close to complete the function is?
The first thing I tried was using library(time) and doing the following:
time<-getTime()
function(inputs)
timeReport(time)
But this just tells me how long it took to complete the function upon completion. Is there a way to know how the function is progressing (percentage completed) as it is running?
I’d love to increase the efficiency of this function, in addition, but that is another question. Thanks all!
You can use a txtProgressBar to keep track of how far you’ve progressed through some process.
I’m not familiar enough with the function you reference to know exactly where it should go, but just from eyeballing it, it looks like it could spend a healthy portion of its time in the loop beginning with:
If you were to use:
That may give you what you’re looking for. Note that some displays work better with certain style progress bars than others. You may have more luck trying different styles when creating your progressbar if the output looks funny to you using the code I posted.
There is no way for R to know in advance how long a generic function will take to complete, so there’s not a generic answer here. Here’s the function you posted with progress bars in each loop.