I was actually trying to model some of what I'm doing after the verbose = TRUE argument in lmer, but had a hard time finding the chunk of code. I'm still looking for it, but got ahead of myself.
-----Original Message----- From: dmba...@gmail.com [mailto:dmba...@gmail.com] On Behalf Of Douglas Bates Sent: Thursday, June 17, 2010 12:14 PM To: Barry Rowlingson Cc: Doran, Harold; r-help@r-project.org Subject: Re: [R] Pretty printing progress On Thu, Jun 17, 2010 at 10:50 AM, Barry Rowlingson <b.rowling...@lancaster.ac.uk> wrote: > On Thu, Jun 17, 2010 at 3:33 PM, Doran, Harold <hdo...@air.org> wrote: >> I have a function that is an iterative process for estimating some MLEs. I >> want to print some progress to screen as the process iterates. I would like >> to try and line things up nicely in the R window, but am not sure the best >> way to do this. Below is a toy example. Suppose I want the value of 10 to be >> just below "iteration" and the value of -1234 to be just below 'Log >> Likelihood'. > > Sure you just dont want to use the progress bar functions from the > plyr package: > > ?plyr::create_progress_bar > > another example of things being in the wrong package.... If you want to stick with a text display you can use the sprintf function to format the strings that you print > cat('Iteration Log Likelihood\n', sprintf("%8d%20g\n", 10, -1234)) Iteration Log Likelihood 10 -1234 I would avoid the tab character as you can't count on the displays of tabs to be consistent. You may also want to change the display of the log-likelihood to be a fixed number of decimal places rather than a general format for floating point numbers, which can switch into the "e" notation for very large or very small numbers. > cat('Iteration Log Likelihood\n', sprintf("%8d%20.4f\n", 10, -1234)) Iteration Log Likelihood 10 -1234.0000 The format of the format strings is another "little language" to learn but it is a very powerful mechanism. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.