Re: [R] NaNs produced as a returned value for a function

2016-02-16 Thread Maram SAlem
Thanks for helping Dunlap. I just don't get why does the function bettarg() executes well if I evaluate it (by hand) step-by step . nut for the same input values , if I tried to execute bettarg() it will give me the error Error in if (y <= accept.prob) { : missing value where TRUE/FALSE needed A

Re: [R] NaNs produced as a returned value for a function

2016-02-14 Thread William Dunlap via R-help
You can do things like while ( !is.nan( r <- randomFunction(x) )) {} # r will be a non-NaN value of randomFunction(x) now or for(i in seq_len(1000)) { if (!is.nan( r <- randomFunction(x))) { break } if (i == 1000) { stop("no good values of randomFuncti

[R] NaNs produced as a returned value for a function

2016-02-14 Thread Maram SAlem
Hi all, I'm trying to write 2 functions(as a part of a larger code) to evaluate a certain equation. The function is : X= c (0.3893094 2.0962311 2.6007558 3.0761810 3.3246947 3.3917976 4.1981546 6.8826140 12.3128013 15.5588470) R=c (0 1 0 0 0 1 1 1 0 1) alpha.update=function(X, R, alpha.c