math equation with multiple levels (if else?) - converting probability into American Odds in Sports Betting


last month


6 time


I have no training in R and I would like to convert the probability of something to American Odds for sports betting. I found the equation online, but I don't know how to write it in R because it involves two levels (an if-statement I believe?). Here is what I need:

1) If implied probability is greater than .5 then I need R to run this formula:

Moneyline Odds = - (implied probability / (100 - implied probability)) x 100

2) If implied probability is less than or equal to .5 then I need R to run this formula and ignore the 1st formula:

Moneyline odds = (100 - implied probability / implied probability ) x 100

Any help in writing this into my script would be much appreciated!

0 answers