## Concatenating numeric values to a vector

1:100
c(1, 2, 3, 4)
c("abc", "def", "ghi")
c(TRUE, FALSE, TRUE)
View Interactive Version

We can combine multiple numbers into a single vector using the concatenate function c() which links elements between the round braces together into a chain. Multiple elements need to be separated by commas.

To create our first vector holding seven different numbers we can use the concatenate function c() like so:

Input
c(7, 4, 2, 5, 5, 22, 1)
Output
[1]  7  4  2  5  5 22  1

Note, that the “[1]” sign before the output above is added by R, and is always added automatically when printing out vectors. If your vectors become bigger you will see more of these prefixes. Just know that they are only added for informational purposes by R, and that they are there to help you while coding. They are not part of the vector itself.

You can see this more clearly, when the output spans over multiple lines:

Input
1:60
Output
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21
[22] 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
[43] 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
Combine values into a vector