Vector can be defined as a data type that includes a list of values of the same type. each value in a vector is called its components, separated by commas. For example, consider C = (1, 2, 3, 4, 5, 6) and it is a vector that contains a list of values of int type.
To find a vector maximum and minimum using the R program, we are using built-in functions max, min for this calculation. The values are passed to these functions directly here.
min(x, na.rm = FALSE)
max(x, na.rm = FALSE)
#where.
STEP 1: Assign variable num with vector values
STEP 2: Use the built-in functions
STEP 3: First print the original values
STEP 4: call max()
with an argument as num to find the maximum value
STEP 5: call min()
with an argument as num to find the minimum value
STEP 6: print the result of each function
num = c(5, 10, 15, 20, 25, 30)
print('Original vector is:')
print(num)
print(paste("Maximum value of the said vector:",max(num)))
print(paste("Minimum value of the said vector:",min(num)))
[1] "Original vector is:" [1] 5, 10, 15, 20, 25, 30 [1] "Maximum value of the said vector: 30" [1] "Minimum value of the said vector: 5"