Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
What are vectors?
2. Creating a numeric vector – the c() function
Vector operations
Indexing and filtering


Nice work! To create a vector, you need to define the values it will contain. You do so with the c() function. For the function arguments, you can include as many comma-separated values as you'd like in your vector:

c(1, 2, 3, 4)

Here we defined a vector that contains four numbers: 1, 2, 3, and 4.

You can assign a vector to a variable like this:

salaries <- c(3400, 2800, 5600, 4200, 3100, 3800, 2700, 6100, 6200, 2400, 1800, 2600)

We've created a vector called salaries that stores the 12 values (salaries) that we specified inside the c() function.


We'd like to analyze salaries by department. Versico has four departments that vary in the number of employees they have. In this case, there are 4, 3, 2, and 3 employees in these four departments. Create a vector named department_employees that contains the numbers of employees in each department, in this precise order.

Stuck? Here's a hint!

You should write:

department_employees <- c(4, 3, 2, 3)