-1

Sorry, I am an R newbie and I am having some difficulty

How would I write the following inequality in R:

x > 10 is twice more likely than x < 10

I tried this function and it didn't work :

X = 10 

f = function(X,Y) { 
  if ((2(X) >= 10 & X <= 10) { 
    print("in range") 
  } else {
    print("out of range") 
  } 
}
Trusky
  • 483
  • 2
  • 13

1 Answers1

0

Your code has a syntax error if that's the problem :

X = 10 
f = function(X,Y) {
  if (2 * X  >= 10 && X <= 10) {  # * instead of (
    print("in range") 
  } else { 
    print("out of range") 
  } 
}

You can try your function as in :

> f(10,10)
[1] "in range"
> f(20,10)
[1] "out of range"
Trusky
  • 483
  • 2
  • 13