Here we are explaining how to write an R program to find the maximum and minimum value of a given vector. Here we are using built-in functions max, min for this calculation. The vector values are passed to these functions directly here. The min() function in R computes the minimum value of a vector or data frame. And the max() function in R computes the maximum value of a vector or data frame.
Below are the steps used in the R program to find the maximum and minimum of vectors. In this R program, we directly give the values to built-in functions. And print the function result. Here we used variable num for assigning vector values.
num = c(5, 10, 15, 20, 25, 30)
print('Original vector is:')
## [1] "Original vector is:"
print(num)
## [1] 5 10 15 20 25 30
print(paste("Maximum value of the said vector:", max(num)))
## [1] "Maximum value of the said vector: 30"
print(paste("Minimum value of the said vector:", min(num)))
## [1] "Minimum value of the said vector: 5"