# Create List of Vectors in R (Example)

On this page youâ€™ll learn how to construct a list of vectors in the R programming language.

Letâ€™s do this.

## Example: Create List of Vectors Using list() Function

The following R code illustrates how to create a list containing different vectors in R.

First, letâ€™s create some example vectors:

```vec1 <- 1:5                          # Create three example vectors
vec2 <- letters[1:7]
vec3 <- rep("x", 3)```

The previous R code has created several vector objects, i.e. one numeric / integer vector and two character vectors.

Letâ€™s combine these vectors in a list!

We can do that by specifying the names of our vectors within the list function:

```my_list <- list(vec1, vec2, vec3)    # Create list of vectors
my_list                              # Print list of vectors
# [[1]]
# [1] 1 2 3 4 5
#
# [[2]]
# [1] "a" "b" "c" "d" "e" "f" "g"
#
# [[3]]
# [1] "x" "x" "x"
#```

Have a look at the previous output of the RStudio console. It shows that we have created a list object containing three vectors each as a separate list element.

## Video, Further Resources & Summary

Do you need more explanations on the contents of this tutorial? Then you might have a look at the following video of my YouTube channel. I illustrate the R programming syntax of this tutorial in the video instruction:

In addition, you may want to read some of the related R programming tutorials of this website: