Intermediate R for Finance
Lore Dirick
Manager of Data Science Curriculum at Flatiron School
if(condition) {
code
}
default_chance <- runif(1)
if(default_chance > .5) { print("Take action! Likely to default!") }
"Take action! Likely to default!"
default_chance
0.9484406
default_chance <- runif(1)
if(default_chance > .5) { print("Take action! Likely to default!") } default_chance
0.3954069
if(condition) {
code if true
} else {
code if false
}
default_chance <- .4
if(default_chance > .5) {
print("Take action! Likely to default!")
} else {
print("No problems here!")
}
"No problems here!"
if(condition1) {
code if condition1 is true
} else if(condition2) {
code if condition2 is true
} else {
code if both are false
default_chance <- .4
if(default_chance > .5) {
print("Take action! Likely to default!")
} else if(default_chance > .3 & default_chance <= .5) {
print("Warning! Starting to get risky.")
} else {
print("No problems here!")
}
"Warning! Starting to get risky."
Intermediate R for Finance