6 Statements and Looping
6.1 Logical Operations
Includes ==, !=, >, <, >=, <=.
Equality: == checks if two values are equal.
Inequality: != checks if two values are not equal.
Greater than: > checks if the value on the left is greater than the value on the right.
Less than: < checks if the value on the left is less than the value on the right.
Greater than or equal to: >= checks if the value on the left is greater than or equal to the value on the right.
Less than or equal to: <= checks if the value on the left is less than or equal to the value on the right.
6.2 Loops
Use for, while.
for loop
The for loop in R is used to iterate over a sequence (like a vector or a list) and execute a block of code for each element in the sequence.
while loop
The while loop executes a block of code as long as the specified condition is TRUE