[R] det(X,log=TRUE)

James Lawrence jdl37 at cam.ac.uk
Wed Jan 19 11:20:11 CET 2011

Hello R-help,

I recently spent a lot of time debugging a program, and the problem
turned out to be my own misuse of the det() function. A simple
recreation of the problem would be

X <- diag (c(2,2,2))
det (X,log=TRUE)

## returns 8 as opposed to log 8

I had simply assumed that (along with many other basic R functions, such
as dnorm etc) det can take an argument of log=TRUE and give you the log
of the answer. At the very least, if it didn't do this, then I would get
an "unused argument" error. The argument "log=TRUE" wasn't used (because
now I have looked at the code for det, I see it supplies its own
argument to determinant()) so is it not possible to  return this error?
I guess it is something to do with the way "..." behaves.

Alternatively, is there a way for me to set up R so that it will tell me
if arguments to functions with "..." aren't really being used?

Many Thanks

James Lawrence.

More information about the R-help mailing list