I was wondering how to set two or more results from a true ifelse statement.
For example, I would like to set y = 2
and t=3
if x=2
. I was thinking the code would look something like this:
x=2
ifelse(x==2,y=2 & t=3, y=0 & t=0)
however this does not work.
You may use if-statement block:
if(x == 2){
y = 2
t = 3
}
else {
y = 0
t = 0
}
Alternatively, you can try:
ifelse(x == 2, {y = 2; t = 3;}, {y = 0; t = 0;})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With