Message-ID: <564E0FB5.6060703@fau.de>
Date: 2015-11-19T18:06:45Z
From: Benjamin Hofner
Subject: format.pval
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