Skip to content

documentation available that further explains error messages?

3 messages · Jeremy Claisse, Kingsford Jones, Ben Bolker

#
Hi Jeremy,

Since R is open source, the code is usually the best reference when
you can't decipher an error message.  Often the easiest way to see
what is going on is to type traceback() after receiving the error
message -- this will show you the calls that led to the error.

Another very useful tool is to type
debug(name.of.function.to.be.debugged) prior to calling the function
of interest.
The next time you use that function, debug will take you step-by-step
through the function calls while allowing full interactive ability so
you can, e.g. look at the structure of objects as they are created
within the function (using, e.g., the str function).

Another option is to open the function's source file in a text window
and use Find in your text editor to find the error.

Finally, searching for the error message in the help archives can
often be fruitful.  That technique just led me to this:

https://stat.ethz.ch/pipermail/r-help/2006-January/086747.html

which indicates what the '[2]' is referring to.


Kingsford Jones
On Wed, May 7, 2008 at 12:30 PM, Jeremy Claisse <jclaisse at yahoo.com> wrote:
#
A couple more suggestions:

  Mark Bravington's "debug" package (mvbdebug, available
on CRAN) can be a more powerful debugging tool if you
want to do a more graphical stepping-through your code;

   a cruder but effective technique is to put a cat()
statement into your objective function, e.g.

  objfun <- function(params,...) {
   ## calculate neg log likelihood
   neg.log.likel <- ...
   cat(params[1],params[2],neg.log.likel,"\n")
   neg.log.likel
}

   that way you can see where the function is getting in
trouble.
Kingsford Jones wrote:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20080507/aef9ad29/attachment.bin>