imax: Obtain largest value index

View source: R/imax.R

imaxR Documentation

Obtain largest value index

Description

Obtains the index of a vector that contains the largest value in the vector.

Usage

imax(z)

Arguments

z

A vector of any length

Value

The index of the largest value in a vector.

Examples

# Iris example
x.iris <- as.matrix(iris[, 1:4])
# Gets group vector (1, ... , 1, 2, ... , 2, 3, ... , 3)
y.iris <- rep(1:3, c(50, 50, 50))
ld.iris <- lda(x.iris, y.iris)
disc <- x.iris %*% ld.iris$a
disc <- sweep(disc, 2, ld.iris$c, "+")
yhat <- apply(disc, 1, imax)

coatless/msos documentation built on Nov. 16, 2023, 5:31 a.m.