In R, the rev()
function is used to reverse the elements of a vector object.
rev(x)
This function takes a single parameter value, x
, representing the vector object of which the elements are to be reversed.
This function returns a vector object with its elements reversed.
# A code to illustrate the rev() function in R# Creating a vector objectda <- c(1, 5, 6, 7, 33, 2, 9)b <- c(1:10)# reversing the elements of the vectorrev(a)rev(b)
a
and b
.rev()
function to reverse the elements in a
and b
.