Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

R Programming: Find the maximum and the minimum value of a given vector

R Programming: Basic Exercise-10 with Solution

Write a R program to find the maximum and the minimum value of a given vector.

Sample Solution :

R Programming Code :

nums = c(10, 20, 30, 40, 50, 60)
print('Original vector:')
print(nums)   
print(paste("Maximum value of the said vector:",max(nums)))
print(paste("Minimum value of the said vector:",min(nums)))

Sample Output:

[1] "Original vector:"
[1] 10 20 30 40 50 60
[1] "Maximum value of the said vector: 60"
[1] "Minimum value of the said vector: 10"                         

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 the factors of a given number.
Next: Write a R program to get the unique elements of a given string and unique numbers of vector.

Test your Programming skills with w3resource's quiz.

What is the difficulty level of this exercise?