OneBite.Dev - Coding blog in a bite size

append item in array in R

Code snippet on how to append item in array in R

arr <-c(1,2,3,4)
arr <- c(arr, 5) 

This R code starts by creating a data object called ‘arr’ that holds the values 1,2,3,4. The last line appends the value 5 to the end of the array. The ‘c’ is a function for combining objects together. In this example it combines the ‘arr’ with 5. The resulting array ‘arr’ would include the values 1,2,3,4 and 5.

r