Skip to content

Latest commit

 

History

History
41 lines (41 loc) · 918 Bytes

04.Conditional Statements.md

File metadata and controls

41 lines (41 loc) · 918 Bytes

Conditional Statements

  • if/else/else if
  • Can be nested
if(TRUE){
    print("Hello")
}

image

#Any number other than 0 is TRUE
x <- 3
if(x){
    print("Hello")
}else{
    print("Hey, There")
}
#if x -> 0, output would be Hey, There

image

y <- 2
if(x == y){
    print("Hello")
}else{
    print("Hey, There")
} 

image

z <- 3
if(x < y & x < z){
    print(x)
} else if(y < x & y < z){
    print(y)
} else{
    print(z)
}
#output -> 1 as x is < than y & z

image