These commands allow you to direct where and how will your scripts evaluate based on the input conditions. For example, if a data column has missing data, you don't want to conduct the same test or you at least want to print a warning to the user.
Also there are loops that will allow you to do the same thing over and over again. Loops are useful for handeling multiple tables, outputting many graphs or randomising milions of data simulations. You probaly don't want to write each simulation as a single line.
In [2]:
compared_num = 10
5 == compared_num
5 < compared_num
5 > compared_num
10 > compared_num
10 >= compared_num
10 < compared_num
Functions can also produce logical return.
In [5]:
nothing = NULL
is.null(nothing)
is.numeric(nothing)
is.character(nothing)
We can negate results by using !
In [ ]:
!is.null(nothing)
10 != compared_num
In [ ]:
condition = TRUE
if(condition){
print("It's true")
}
We can also use else statememt to do other stuff instead.
In [ ]:
condition = TRUE
if(condition){
print("Its true")
} else {
print("It'S sooo false")
}
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
Let's combine all together
In [ ]:
games = c("CS Files", "Terra Mystica", "Cosmic Encounter", "Pandemic", "Takenoko", "Survive", "Stronghold", "Bang")
is_good = function(name){
bad_games = c("Bang", "Survive", "Stronghold")
if()
}