[R] Confused about a warning message

David Winsemius dwinsemius at comcast.net
Fri Jul 8 02:52:19 CEST 2011


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.

>
> Thanks,
> Gang
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list