OneBite.Dev - Coding blog in a bite size

reverse arrays items in R

Code snippet on how to reverse arrays items in R

  rev(x)

This code uses the built-in R function called rev() to reverse the items of an array. The function requires one input, which should be the array that you want to reverse. The rev() function will return a new array with the items in the same shape as the original, but in reversed order. For example, if the original array was [1,2,3], the output of the rev() function would be [3,2,1]. The rev() function can be used for any type of arrays, including numerical, character, and logical arrays. This makes it a very useful tool when working with array data.

r