list.append() Function in R

list.append() function is used to add value to the list. This guide will explain the list.append() Function in R.

list.append() Syntax

list.append(.data, ...)

Arguments

  • .data – the list to which you want to append
  • – the element you want to append to the list

Installing the rlist Package

list.append() comes from the rlist package. To install and load the package, run the following code:

install.packages('rlist')
library('rlist')

Example: Appending value to the list

#loading the rlist library
library('rlist')
#creating a list
heroes <- list('batman','superman')
#appending a new value and assigning to the list
heroes <- list.append(heroes, 'flash')
#printing the list
heroes

Output

[[1]]
[1] "batman"
[[2]]
[1] "superman"
[[3]]
[1] "flash"

Leave a Comment