Learn R Programming

yaImpute (version 1.0-34.1)

whatsMax: Find maximum column for each row

Description

For each row, the function identifies the column that has the maximum value. The function returns a data frame with two columns: the first is the column name corresponding to the column of maximum value and the second is the correspond maximum. The first column is converted to a factor.

If the maximum is zero, the maximum column is identified as "zero".

If there are over nbig factors in column 1, the maximum values that are less than the largest are combined and identified as "other".

Intended use is to transform community ecology data for use in yai where method is randomForest.

Usage

whatsMax(x,nbig=30)

Value

A data frame.

Arguments

x

a data frame or matrix of numeric values.

nbig

see description--the maximum number of factors, the remainder called 'other'.

Author

Nicholas L. Crookston ncrookston.fs@gmail.com
Andrew O. Finley finleya@msu.edu

Examples

Run this code
data(MoscowMtStJoe)

# get the basal area by species columns
yba  <- MoscowMtStJoe[,1:17]

# for each row, pick the species that has the max basal area
# create "other" for those not in the top 7.

ybaB <- whatsMax(yba,nbig=7)
levels(ybaB[,1])

Run the code above in your browser using DataLab