R append to list: How to Append Element in R List

R list is a data structure having elements of different data types. To create a list in R, use the list() function. To access the list, use indexing. You can use integer, logical, or character vectors for indexing.  List in R can be modified that means you can add, update, or delete the list components.

R append to list

To append an element in the R List, use the append() function. You can use the concatenate approach to add components to a list. While concatenate does a great job of adding elements to the R list, the append() function operates faster.

The append() function also allows us to define where to append the values within the list or vector. This will add the elements after the named element.


append(data, ...)



It is a list or vector.


It is a vector or list to append after x.

R code to append an element to a list

list1 <- list(a = 1, b = 2, c = 3)
list2 <- list(d = 4)
appended_list <- append(list1, list2)


[1] 1

[1] 2

[1] 3

[1] 4

In this example, we appended a list element to the list using the append() element.

R append element to Vector

To append an element to vector at the last position, use the third parameter called after and specify the index, after which you want to append a new element.

rv1 <- c(10, 20, 30, 40)
rv2 <- append(rv1, 50, after = 40)


Rscript Pro.R
[1] 10 20 30 40 50

In this example, we are appending an item after the specific component. In our case, it is 40, and it is last.

Using c() function to append to element to Vector in R

You can use the c() function to append values to a vector. It is a straightforward approach to append elements in the R Vector.

rv1 <- c(10, 20, 30, 40)
newel <- 50
rv1 <- c(rv1, newel)


[1] 10 20 30 40 50


To append an element to a list or to append an element to a Vector in R, use the append() function. That is it for this R append to list tutorial.

See also

R Matrix

R Array

Leave a Comment