What are vectors?
Vector operations
12. Arithmetic with vectors: combining operations
Indexing and filtering
Simple analysis
Summary

Instruction

Good job! We can also combine operations when working with vectors! For example, suppose the salaries over the past two months are stored in salaries and salaries_last_month. We can calculate the average salary over the last two months for each employee with the following code:

(salaries+salaries_last_month)/2

R will apply the standard order of operations to first perform the calculations within the parentheses (in this case, addition) and then move on to division.

Exercise

An employee's annual salary is equal to their monthly salary multiplied by 12. Monthly salaries are stored in the salaries vector. The yearly bonuses are stored in bonuses. Calculate the total annual salary for each employee after the bonuses are applied.