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.