Slip 2 - E) Write an R program to sort a Vector in ascending and descending order.

Solution:

x = c(10, 20, 30, 25, 9, 26)
print("Original Vectors:")
print(x)
print("Sort in ascending order:")
print(sort(x))
print("Sort in descending order:")
print(sort(x, decreasing=TRUE))

Post a Comment

0 Comments