whatsMax {yaImpute} | R Documentation |
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)
Arguments
x |
a data frame or matrix of numeric values. |
nbig |
see description–the maximum number of factors, the remainder called 'other'. |
Value
A data frame.
Author(s)
Nicholas L. Crookston ncrookston.fs@gmail.com
Andrew O. Finley finleya@msu.edu
Examples
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])