What are vectors?
7. Combining vectors
Vector operations
Indexing and filtering
Simple analysis
Summary

Instruction

Great! You can also combine vectors of the same data type to produce a bigger vector.

Suppose the four vectors that follow represent the salaries of employees in Versico's four departments:

salaries_dep_1 <- c(3400, 2800, 5600, 4200)
salaries_dep_2 <- c(3100, 3800, 2700)
salaries_dep_3 <- c(6100, 6200)
salaries_dep_4 <- c(2400, 1800, 2600)
You can easily combine these vectors with the c() function. Pass the individual vector names, separated by commas, into the function as the arguments, like so:

salaries <- c(salaries_dep_1, salaries_dep_2, salaries_dep_3, salaries_dep_4)

The vector salaries will now contain all elements from all four vectors.

Exercise

We've created vectors names_dep1, names_dep2, names_dep3, and names_dep4 that store the names of employees in each department.

Combine these vectors into a single vector called names.