[R] how to show iterations

Pieter Schoonees schoonees at ese.eur.nl
Sun Oct 14 19:19:16 CEST 2012

If you are writing the loop yourself, you can use print() statements in the loop. If you are using something like optim(), have a look at the documentation and use the trace option under the control argument. Otherwise, put a print statement in the function you are passing to optim. If this fails you can try to edit the default optimization function with fix() to add a print statement where you want it, if the documentation shows that a trace argument is not already built in. 

Otherwise be more specific with your question please, e.g. include example code. To combine text and the values of object in an print statement, use paste().

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On Behalf Of sffarooqi
> Sent: Sunday, October 14, 2012 17:36
> To: r-help at r-project.org
> Subject: [R] how to show iterations
> Hi,
> I am new to R, and am working on some optimization problems - I was
> wondering if there was a way that I could show all the iterations in R -i.e.
> showing for each iteration, what the iteration is, how much the function is,
> what the norm of the gradient would be...
> Any help is greatly appreciated!
> thank you!!
> --
> View this message in context: http://r.789695.n4.nabble.com/how-to-show-
> iterations-tp4646133.html
> Sent from the R help mailing list archive at Nabble.com.
> ______________________________________________
> R-help at 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.

More information about the R-help mailing list