How to add/append an item to a list in R?

How to add/append an item to a list in R?

R ¨C Add/Append Item to List

To add an item to a list in R programming, call append() function and pass the list and item as arguments in

the function call.

In this tutorial, we will learn how to add or append an element to a list in R, using append() function, with the

help of example programs.

Syntax

The syntax to of append() function is

append(myList, item, after = index)

The append() function appends the item item after specified position index in the list myList .

after parameter is optional. If no index is provided for after parameter, the item is appended at end of

the list.

append() function does not modify the original list, but returns a new list.

Examples

In the following program, we will create a list with some initial values, and then append items to it using append()

function.

example.R

myList ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download