I've looked at a couple of questions but couldn't find a solution that doesn't use loops. I've looked here and here. Now, how could I add a progress bar that works exactly at the same time as this function:
prog<-function(){
print("This is a test")
Sys.sleep(05)
setTxtProgressBar()
}
The above is a dummy function and I thought of using system.time
to capture the time it takes for the print command to execute and use this for the progress bar. How could I make this work, without using a for loop?
EDIT
I tried this but it is still slow:
prog<-function(y=sort(runif(200)),...){
pb<-txtProgressBar(...)
values<-c(0,y,1)
lapply(values, function(x){
Sys.sleep(0.5)
setTxtProgressBar(pb,x)})
Sys.sleep(1)
close(pb)
}
Thanks.