Skip to content

Instantly share code, notes, and snippets.

@cgpu
Forked from jilmun/print_progress.R
Created February 16, 2020 23:26
Show Gist options
  • Select an option

  • Save cgpu/8a0e59f47c9c2b12778548d92f6b52a3 to your computer and use it in GitHub Desktop.

Select an option

Save cgpu/8a0e59f47c9c2b12778548d92f6b52a3 to your computer and use it in GitHub Desktop.
# print everything after loop is finished
for (i in 0:101) {
print(i)
Sys.sleep(0.01)
}
# simplist way to print within loop
for (i in 0:101) {
print(i)
Sys.sleep(0.01)
flush.console()
}
# fancier text progress
# install.packages("svMisc")
require(svMisc)
for (i in 0:101) {
progress(i)
Sys.sleep(0.01)
if (i == 101) cat("Done!\n")
}
# fancier text progress with bar
# install.packages("svMisc")
require(svMisc)
for (i in 0:101) {
progress(i, progress.bar = TRUE)
Sys.sleep(0.01)
if (i == 101) cat("Done!\n")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment