| Start |
|---|
| Range and addition Let's take an example of adding a value to a range (as it could be done in a loop for example): Gives: This is because the range operator What happens during evaluation is as follows:
To avoid this behavior you have to tell the R interpreter how you want it to order the operations with Now R will compute what is inside the parentheses before expanding the range and gives: |
| Addition and subtraction The basic math operations are performed mainly on numbers or on vectors (lists of numbers). 1. Using single numbers We can simple enter the numbers concatenated with We can assign the numbers to variables (constants in this case) and do the same operations: 2. Using vectors In this case we create vectors of numbers and do the operations using those vectors, or combinations with single numbers. In this case the operation is done considering each element of the vector: We can also use the function We must take care with recycling, which is one of the characteristics of In this case the correct procedure will be to consider only the elements of the shorter vector: When using the RemarksNearly all operators in R are really functions. For example, For example: |
Read Article
https://develop.horje.com/learn/1434/reference