-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathIf Else Else If Statements.R
66 lines (50 loc) · 1.05 KB
/
If Else Else If Statements.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# If, else, and else if Statements
x <- 13
if(x == 10){
print('x is equal to 10')
}else if (x==12){
print('x equal to 12')
}else{
print('x was not equal to 10 or 12')
}
hot <- TRUE
temp <- 100
if(temp > 80){
# Execute if condition was true
print('Temp is greater than 80')
}
print(hot)
temp <-30
if (temp>80){
print('Hot Outside!')
}else{
print( 'Temp is not greater than 80')
}
if (temp <= 80 & temp >=50){
print('Nice Outside!')
}else{
print("It's less than 50 degrees outside")
}
ham <- 10
cheese <- 10
report <- 'blank'
if(ham >=10 & cheese >=10){
report <- "Strong sales of both ham and cheese"
}else if(ham == 0 & cheese == 0){
report <- "No sales today!"
}else{
report <- "We sold something today!"
}
print(report)
# 5
ham <- 5
cheese <- 5
report <- 'blank'
if(ham >=10 & cheese >=10){
report <- "Strong sales of both ham and cheese"
}else if(ham == 0 & cheese == 0){
report <- "No sales today!"
}else{
report <- "We sold something today!"
}
print(report)