spatial.tools (version 1.6.0)

which.max.simple: Location of Maximum Value

Description

Locates the largest value of the input object.

Usage

which.max.simple(x, na.rm = TRUE, tie_value = "NA")

Arguments

x

a numeric object

na.rm

a logical indicating whether missing values should be removed.

tie_value

A character indicating how to deal with ties. Can be "NA" (returns an NA if a tie is found) or "random" (returns a single randomly chosen member of the ties if a tie is found) or "first" (returns the first class found).

Value

An integer of length 1 giving the index of the maximum of x or NA if the maximum of x is not unique, x has no non-NAs, or na.rm=F.

See Also

which.max, which, max

Examples

Run this code
# NOT RUN {
x<-c(2:4,1,1,NA)
y<-c(4,1:3,NA,4)
## The index is only calculated for a unique maximum
which.max.simple(x)
which.max.simple(y)
which.max.simple(y,na.rm=FALSE)
which.max.simple(x,na.rm=FALSE)
# }

Run the code above in your browser using DataCamp Workspace