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

Bill Denney bill at denney.ws
Wed Jul 20 21:13:58 CEST 2016


Hi François,

I thought that was the issue, too, but I confirmed it wasn't that by 
adding a print statement right above the warning in my code. The print 
statement displays the message even when the warning (one line below 
with no conditionals between) doesn't show anything.

Also, why would it behave differently when options(warn=1) is set rather 
than the default of options(warn=0)?

Thanks,

Bill


On 7/20/2016 3:06 PM, François Michonneau wrote:
> Hi Bill,
>
>    The problem is not with the warning() function but with your if()
> test that triggers the warning. It probably has something to do with
> slight differences in rounding. I suggest you use debug() or browser()
> on each platform to see why your condition is TRUE or FALSE.
>
>    Cheers,
>    -- François
>
> On Wed, Jul 20, 2016 at 2:42 PM, Bill Denney <bill at denney.ws> wrote:
>> 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
>>
>> ______________________________________________
>> R-package-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-package-devel



More information about the R-package-devel mailing list