What are vectors?
Vector operations
8. Arithmetic operations on vectors
Indexing and filtering
Simple analysis
Summary

Instruction

Great! Interestingly, you can add and subtract constant values from a vector. These arithmetic operations are applied to each element of the vector. For example, if we write

salaries + 250

R will create a new vector that is the result of adding the number 250 to each element of the vector salaries:

salaries
[1] 3400 2800 5600 4200 3100 3800 2700 6100 6200 2400 1800 2600 

salaries + 250
[1] 3650 3050 5850 4450 3350 4050 2950 6350 6450 2650 2050 2850

The original vector's elements remain unchanged. If you want to update its elements, you need to assign the result of this addition back to the vector, like so:

salaries <- salaries + 250

Exercise

The vector salaries stores the monthly salaries of each employee. Convert all values in this vector so they represent the annual salaries of each employee. Assign the converted values to the annual_salaries vector.