I wish to do the following:
if X>Y and
Z>A and
B>Y then print ("SUCCESS")
else LOAD NEXT VARIABLES AND REPEAT
What would be the best way to go about this in r?
I wish to do the following:
if X>Y and
Z>A and
B>Y then print ("SUCCESS")
else LOAD NEXT VARIABLES AND REPEAT
What would be the best way to go about this in r?
X = 2
Y = 1
Z = 4
A = 2
B = 2
if( X > Y & Z > A & B > Y){
print("SUCCESS")
}else{
print("do somethng else")
}
# similarly
#if( X > Y && Z > A && B > Y){
# print("SUCCESS")
# }else{
# print("do somethng else")
#}
###################################
To repeat the function it might be easier to do:
repeat{
X = sample(1:10, 1)
Y = sample(1:10, 1)
Z = sample(1:10, 1)
A = sample(1:10, 1)
B = sample(1:10, 1)
if( X > Y & Z > A & B > Y){
print("success")
break
}
}
working on this sort of logic:
n = 1
repeat{
print("success")
n <- n+1
if( n > 10){
print("stop now")
break
}
}
#[1] "success"
#[1] "success"
#[1] "success"
#[1] "success"
#[1] "success"
#[1] "success"
#[1] "success"
#[1] "success"
#[1] "success"
#[1] "success"
#[1] "stop now"