Re: [Rd] p.adjust; n > length(p) (PR#13519)

From: Steven McKinney <>
Date: Wed, 11 Feb 2009 12:13:17 -0800

Hi Ludo,

Issues such as this are best posed as
questions to the list before filing a bug report. (False bug reports create extra work for volunteer R-core members.)

What is your use case for setting
n larger than length(p) (the default)?

The documentation does say
"n number of comparisons, must be at least length(p); only set this

   (to non-default) when you know what you are doing!"

Because the default
n = length(p)
is not evaluated until n is first needed in the function body ('lazy evaluation') n is by default set to length(p) after NAs
are removed in about line 8 of the function line "stopifnot(n >= length(p))" )

and I'm not finding any problems with the function, even when supplying p-values with NAs.

The documentation also states
"Note that you can set n larger than length(p) which means the unobserved p-values are assumed to be greater than all the observed p for "bonferroni" and "holm" methods and equal to 1 for the other methods."

so it is up to the user to properly interpret the function output when using a non-default setting for n. The ensuing warning is just a warning, not an error, requiring proper interpretation and understanding by the user that chooses to set n to a non-default setting.

> -----Original Message-----
> From:
> On Behalf Of
> Sent: Wednesday, February 11, 2009 7:10 AM
> To:
> Cc:
> Subject: [Rd] p.adjust; n > length(p) (PR#13519)
> Full_Name: Ludo Pagie
> Version: 2.8.1
> OS: linux
> Submission from: (NULL) (
> p.adjust in stats seems to have a bug in handling n>length(p) for (at
> least) the
> methods 'holm' and 'hochberg'.
> For method 'holm' the relevant code:
> i <- 1:n
> o <- order(p)
> ro <- order(o)
> pmin(1, cummax((n - i + 1) * p[o]))[ro]
> where p is the supplied vector of pvalues and n is the supplied number
> comparisons. If n>length(p) p.adjust() gives a warning:
> Warning message:
> In (n - i + 1) * p[o] :
> longer object length is not a multiple of shorter object length
> to me it seems that instead of 'i <- 1:n', 'i <- 1:length(p)' is

This is the case if you do not specify n. Lazy evaluation yields n = length(p)

> Similar cases seem to be true for 'hochberg' and possibly other
> (I tried checking whether this bug has been reported but the website
> on
> me. appologies if the bug is known already)
> Best, Ludo
> Netherlands Cancer Institute
> Gene Regulation (B4)
> van Steensel Group
> Plesmanlaan 121
> 1066 CX Amsterdam
> The Netherlands
> Tel.: ++ 20 512 7986
> Fax: ++ 20 669 1383
> email:
> ______________________________________________
> mailing list


Steven McKinney, Ph.D.

Molecular Oncology and Breast Cancer Program British Columbia Cancer Research Centre

tel: 604-675-8000 x7561

Molecular Oncology
675 West 10th Ave, Floor 4
Vancouver B.C.
V5Z 1L3

Canada mailing list Received on Wed 11 Feb 2009 - 19:21:12 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 11 Feb 2009 - 22:30:22 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive