Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
What are vectors?
Vector operations
12. Arithmetic with vectors: combining operations
Indexing and filtering


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:


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.


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.