[Rd] format.pval

Benjamin Hofner benjamin.hofner at fau.de
Thu Nov 19 19:06:45 CET 2015


Today I stumbled upon a very strange behaviour of format.pval. If all p 
values are below the threshold eps one gets

format.pval(c(0.0002, 0.0004), eps = 0.001)
## [1] "< 0.001" "< 0.001"
format.pval(0.0004, eps = 0.001)
## [1] "< 0.001"

i.e., "< [eps]" as described in the manual of format.eps.


Yet, if one ore more are above (and one or more below) one gets

format.pval(c(1, 0.0004), eps = 0.001)
## [1] "1" "<0.001"

i.e., "<[eps]", without the blank after <.


One can also change this by setting digits = 1

format.pval(c(0.0002, 0.0004), eps = 0.001, digits = 1)
## [1] "<0.001" "<0.001"

 From the code I've learned that

sep <- if (digits == 1L && nc <= 6L) "" else " "

if any p values are above eps (nc = max(nchar(pv)) and

sep <- if (digits == 1) "" else " "

if all p values are  smaller than eps.

(Why) is this behaviour intended? I do not see any reason for the 
different outputs (nor for the arbitrary nc threshold). Yet, if it is 
intended it should be documented.

Best,
Benjamin



More information about the R-devel mailing list