r - problems with user defined function -


i have trouble when running r code. contains few functions, problem happens when following function called:

w <- function(p) {     if (p == 1) pr <- 1    if (p == 0) pr <- 0    if (p != 0 && p != 1) pr <- exp(-(-log(p))^sigma)     return(pr) } 

the problem occurs when argument of w function becomes 1. checked step step execution. found when have w(c1) in other function , c1 has value of 1, return of w function nan. confused because when write w(1), 1, when have w(c1), c1 computed 1 in other function, w function not work. in step step execution, when c1 becomes 1, first if condition not work, returns false, should opposite, since c1 equal 1.

what can solution problem?


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -