if statement - >= not working, R -


this question has answer here:

i running code below. function ax returtns value 1. ifelse statement not recognize ax==1.

i've tried making output of function double-precision , numeric values double. hasn't worked.

i hoping:
1) troubleshooting specific case
2) tips on how avoid problem in future

axfun<-function(beta,gamma,a,b,g,h0stud,wh,wi){    ((b*beta + g*gamma)*(1 + 2*g*gamma)*(1 + gamma + b*((-beta)*(1 + gamma) + a*(-1 + beta)*(1 + g*gamma)))*h0stud*wi)/     ((-1 + b*beta)*(1 + gamma)*((-g)*gamma*(1 + 2*g*gamma)*wi + b*beta*((-1 + g*gamma*(-2 + h0stud) + h0stud)*wh - (1 + g*gamma)*h0stud*wi))) }  ax<-axfun(2^1,           2^0,           2^0,           2^-3,           2^-1,           1,           1,           0.4)  ifelse(ax>=1, 0, ax) 

there nothing wrong >=, problem 1 not one. try this

ax >= 1 [1] false ax == 1 [1] false 

and

format(ax, digits = 20) [1] "0.99999999999999977796" 

edit: possible solution

as solutions problems can return final result of function object , use ceiling function.

if have work such results maybe read of circle 1 of r inferno thing do. can find here.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -