Write a R program to sort a Vector in ascending and descending order.
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))
Sample Output:
[1] "Original Vectors:" [1] 10 20 30 25 9 26 [1] "Sort in ascending order:" [1] 9 10 20 25 26 30 [1] "Sort in descending order:" [1] 30 26 25 20 10 9
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer