[R] Confused about a warning message
David Winsemius
dwinsemius at comcast.net
Fri Jul 8 03:04:50 CEST 2011
On Jul 7, 2011, at 8:52 PM, David Winsemius wrote:
>
> On Jul 7, 2011, at 8:47 PM, Gang Chen wrote:
>
>> I define the following function to convert a t-value with degrees
>> of freedom
>> DF to another t-value with different degrees of freedom fullDF:
>>
>> tConvert <- function(tval, DF, fullDF) ifelse(DF>=1, qt(pt(tval, DF),
>> fullDF), 0)
>>
>> It works as expected with the following case:
>>
>>> tConvert(c(2,3), c(10,12), 12)
>> [1] 1.961905 3.000000
>>
>> However, it gives me warning for the example below although the
>> output is
>> still as intended:
>>
>>> tConvert(c(2,3), c(0,12), 12)
>> [1] 0 3
>> Warning message:
>> In pt(q, df, lower.tail, log.p) : NaNs produced
>>
>> I'm confused about the warning especially considering the fact that
>> the
>> following works correctly without such warning:
>>
>>> tConvert(2, 0, 12)
>> [1] 0
>>
>> What am I missing?
>
> The fact that ifelse evaluates both sides of the consequent and
> alternative.
I also think you should update yur R to the most recent version since
a current version does not issue that warning.
--
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list