Q:

Write a R program to sort a Vector in ascending and descending order

0

Write a R program to sort a Vector in ascending and descending order.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now