Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress a progress bar in R

Tags:

r

progress-bar

The HOF function in the eHOF package of R automatically generates a progress bar. There is no argument in the function to turn off the progress bar.

Is there any way to suppress the generation of the progress bar outside of the function? (I am applying the function many hundreds of times, and the progress bars currently serve no purpose other than to flood my screen.)

like image 646
Andy Avatar asked Feb 06 '23 13:02

Andy


1 Answers

As per @hrbrmstr's suggestions.

# Load the library
library("eHOF")

# Generate a fake dataset
FakeData<-sample(c(0,1),250,replace=TRUE)
TestMatrix<-matrix(FakeData,nrow=50,ncol=5)

# Apply the HOF function to each column of the matrix, and suppress progbar
# Use invisible to prevent capture.output from printing the progbar
invisible(capture.output(Models<-apply(TestMatrix,2,HOF,1:50)))

# Apply the Para function to extract the model parameters
DesiredOutcome<-sapply(Models,Para)
like image 71
Andy Avatar answered Feb 26 '23 12:02

Andy