get.unique.matrix: Get unique rows/columns of a matrix with an index vector.

View source: R/utils.R

get.unique.matrixR Documentation

Get unique rows/columns of a matrix with an index vector.

Description

A wrapper for the table.matrix function that assigns consecutive row or column names to the output matrix's unique rows or columns.

Usage

get.unique.matrix(data, MARGIN = 2, silent = TRUE)

Arguments

data

A matrix or data.frame, potentially containing non-unique patterns in its rows or columns.

MARGIN

A single integer specifying the array margin to be held fixed. (To get unique rows, select MARGIN = 1; for unique columns, select MARGIN = 2.)

Details

An extension of the base unique.matrix function, get.unique.matrix returns a unique matrix (by removing duplicate rows or columns), as well as an index vector that maps each row/column in the original matrix to the corresponding unique row or column in the deduplicated unique matrix.

Value

A list with the following elements:

  • index

    An index vector containing the indices (row numbers), in a matrix composed only of unique rows, to which each row in the original matrix maps.

  • unique.data

    A new matrix containing only the unique rows of the input matrix.

Author(s)

Caitlin Collins caitiecollins@gmail.com


caitiecollins/treeWAS documentation built on Feb. 11, 2025, 11:25 a.m.