/>
小さな工夫と発見の蓄積
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
ただいまコメントを受けつけておりません。
cat
を使う。flush.console
は現在の環境では必要なかったが、おまじないとして書いておく。Sys.sleep
。'='*10
のような、シンプルに繰り返し文字列をつくるコマンドはないようだ。N <- 500 for (n in 1:N) { cat(sprintf('\r[%-20s %3.0f%%]', paste(rep('=', n/N*20), collapse=''), n/N*100)) flush.console() Sys.sleep(.01) }
N <- 500 for (n in 1:N) { ch <- substring('-<>', (n %% 3) + 1, (n %% 3) + 1) ch <- paste(rep(ch, 10), collapse='') cat(sprintf('\r%s %3d/%3d %s', ch, n, N, ch)) flush.console() Sys.sleep(.05) }