OneBite.Dev - Coding blog in a bite size

add new item in array in R

Code snippet on how to add new item in array in R

arr <- append(arr, newItem)

This code adds an element, “newItem”, to the end of an existing array, “arr”. The command “append” is used to add an element to the end of an array. The first argument specifies the array to be modified and the second argument specifies the element to be added. In this example, “arr” is the existing array, and “newItem” is the new item that will be appended to the end of the array.

r