[R-pkg-devel] Warning that are Unintentionally OS-Specific (Maybe Bug in warning?)

Bill Denney bill at denney.ws
Wed Jul 20 20:42:51 CEST 2016


Hi,

I'm developing the PKNCA package, and I've got an odd difference between 
warning behavior on different operating systems that I can't figure out.

When I run the following code on Windows 10 (with R 3.3.0), I get the 
following warning:

library(PKNCA)
source("https://raw.githubusercontent.com/billdenney/pknca/master/tests/testthat/generate.data.R")
tmpconc <- generate.conc(2, 1, 0:24)
tmpconc$conc <- 0
tmpdose <- generate.dose(tmpconc)
myconc <- PKNCAconc(tmpconc, conc~time|treatment+ID)
mydose <- PKNCAdose(tmpdose, dose~time|treatment+ID)
mydata <- PKNCAdata(myconc, mydose)
myresult <- pk.nca(mydata)

Warning messages:
1: In pk.calc.half.life(conc = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  :
   Too few points for half-life calculation (min.hl.points=3 with only 0 
points)
2: In pk.calc.half.life(conc = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  :
   Too few points for half-life calculation (min.hl.points=3 with only 0 
points)

When I run the code on Linux (Ubuntu 16.04 with R 3.3.1), I do not get a 
warning.  When I run the code on Linux after "options(warn=1)", I get 
the warning.  I have confirmed that the same code path is taken in both 
Windows and Linux by simply inserting a print statement next to the 
warning.  The actual warning code is:

     warning(sprintf(
       "Too few points for half-life calculation (min.hl.points=%g with 
only %g points)",
       min.hl.points, nrow(dfK)))

This platform inconsistency is causing issues with my package because 
the package expects the warnings, and the user should know about the 
warnings.  I've got test cases expecting the warnings, and they fail 
everywhere but Windows 
(https://cran.r-project.org/web/checks/check_results_PKNCA.html).

Does anyone have an idea why warnings may behave differently on Windows 
compared to non-Windows platforms?  Is this a bug in R somewhere?  (I've 
not been able to make a simpler example that triggers the issue, 
unfortunately.)

Thanks,

Bill



More information about the R-package-devel mailing list