max
Introduction
max
is one of many simple numerical functions you can use to analyze a vector in R. It returns the maximum value in a vector or column in a data.frame.
Some additional applications of this include comparing the maximum values between columns, finding the maximum value of a row, and finding a string that’s alphabetically last in a list.
Examples
What is the biggest value in the vector weights
?
weights <- c(147, 280, 180, 190, 145)
max(weights)
[1] 280
What is the largest response over an experiment
data.frame with trial1
, trial2
, and trial3
as its trial columns?
max(c(experiment$trial1, experiment$trial2, experiment$trial3))
[1] 87