w3resource

R Programming: Find the minimum and the maximum of a Vector

R Programming: Vector Exercise-8 with Solution

Write a R program to find the minimum and the maximum of a Vector.

Sample Solution :

R Programming Code :

x = c(10, 20, 30, 25, 9, 26)
print("Original Vectors:")
print(x)
print("Maximum value of the above Vector:")
print(max(x))
print("Minimum value of the above Vector:")
print(min(x))

Sample Output:

[1] "Original Vectors:"
[1] 10 20 30 25  9 26
[1] "Maximum value of the above Vector:"
[1] 30
[1] "Minimum value of the above Vector:"
[1] 9                         

R Programming Code Editor:



Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a R program to find Sum, Mean and Product of a Vector, ignore element like NA or NaN.
Next: Write a R program to sort a Vector in ascending and descending order.

Test your Programming skills with w3resource's quiz.

What is the difficulty level of this exercise?



Follow us on Facebook and Twitter for latest update.