[Rd] na.omit option in prcomp: formula interface only

Ben Bolker bbolker at gmail.com
Thu Feb 9 17:45:52 CET 2012

  This is a wishlist/request for discussion about the behaviour of the
na.action option in prcomp, specifically the fact that it only applies
to the formula interface.

   I had a question from a friend (who is smart and careful and
generally R's TFM, although like all of us he misses things sometimes)
asking why the na.action= argument didn't seem to be doing anything in
prcomp (i.e. one gets an "Error in svd(x, nu=0): infinite or missing
values in 'x'").  Some poking later, I realized that na.action only
applied to the formula interface (so I told him to try
prcomp(~.,data=x,...) instead).  Sufficiently careful reading of the
help page, with hindsight, revealed that na.action only appears in the
arguments for the formula method, not the default (on the other hand,
'scale.' only appears in the default formula, but it *does* work with
prcomp.formula as well, because prcomp.formula passes ... through to
prcomp.default ...)

  Would it be reasonable to (at least) add a sentence to the
documentation saying that na.action applies only to the formula
interface or (possibly) to add some NA-processing machinery to
prcomp.default to allow it to handle na.action as well?  (I can
appreciate from looking at stats:::prcomp.formula that the NA-processing
is not completely trivial ...)

  Ben Bolker

More information about the R-devel mailing list