Expressions and Operators
An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. R language is rich in built-in operators and provides following types of operators.
An expression is a combination of one or more operands, zero or more operators, and zero or more pairs of parentheses.
There are three kinds of expressions:
- An arithmetic expression evaluates to a single arithmetic value.
- A character expression evaluates to a single value of type character.
- A logical or relational expression evaluates to a single logical value.
The operators indicate what action or operation to perform. For more information of Expressions and operators click on this link Expressions and Operators
Loops
There are many different kinds of loops, but they all essentially do the same thing: they repeat an action some number of times.
A “For” Loop is used to repeat a specific block of code a known number of times. For example, if we want to check the grade of every student in the class, we loop from 1 to that number. When the number of times is not known before hand, we use a “While” loop.
A for loop repeats until a specified condition evaluates to false. The JavaScript for loop is similar to the Java and C for loop.
for ([initialExpression]; [conditionExpression]; [incrementExpression])
statement
for (let step = 0; step < 5; step++) {
// Runs 5 times, with values of step 0 through 4.
console.log('Walking east one step');
}
A while statement executes its statements as long as a specified condition evaluates to true. A while statement looks as follows:
While loops are loops that will continue to go until a condition is no longer true. The reason they are called while loops because the code will repeat while a condition is still true. You can think of while loops as telling your app “while this happens, repeat this” or “while this hasn’t changed, repeat this”.
while (condition)
statement
For more examples of looping click here! Looping