Hi,
I would like to execute the following vectorized calculation:

  ans <- ifelse (k >= -1 & k <= n, pbeta(p, k+1, n-k, lower.tail = FALSE), 
ifelse (k < -1, 0, 1) )

For example:


> k <- c(-1.2,-0.5, 1.5, 10.4)
> n <- 10
> ans <- ifelse (k >= -1 & k <= n, pbeta(p,k+1,n-k,lower.tail=FALSE), ifelse (k 
> < -1, 0, 1) )
Warning message:
In pbeta(p, k + 1, n - k, lower.tail = FALSE) : NaNs produced
> print(ans)
[1] 0.000000000 0.006821826 0.254991551 1.000000000

The answer is correct.  However, I would like to eliminate the annoying 
warnings.  Is there a better way to do this?

Thank you,
Ravi


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to