Learn R Programming

ivmte (version 1.0.1)

maxminmatch: Auxiliary function: finding the max/min within a group in a data set

Description

This function takes the a data set data. Assuming the data has a column with the name stored in the group argument indicating the groups (see groupby), and a column with the count variable that ranks the elements in the group (data is assumed to be ordered by (group, rank)); this function returns a dummy indicator for each row in data that equals to 1 if the count entry matches that of type, which can either be max or min (i.e. either the largest in the group, or the smallest).

Usage

maxminmatch(data, count = ".mst.monoc", group = ".mst.monog", type)

Arguments

data

data.frame that user wishes to determine the row with the largest or smallest ranking within each group.

count

string of column name indicating the ranking of each row within a group.

group

string of column name indicating the group of each row.

type

input "max" to tag the row in each group with the largest rank, and "min" to tag the row in each group with the smallest rank.

Value

A binary vector indicating whether or not each corresponding row in data is the max/min within its group.