uniquifyDataFrameByGroup: Groupwise unique rows of a DataFrame

View source: R/uniquifyDataFrameByGroup.R

uniquifyDataFrameByGroupR Documentation

Groupwise unique rows of a DataFrame

Description

Obtain unique values for groups of rows in a DataFrame. This is used by aggregateAcrossCells to obtain colData for the aggregated SummarizedExperiment.

Usage

uniquifyDataFrameByGroup(x, grouping)

Arguments

x

A DFrame.

grouping

A factor (or a vector coercible into a factor) of length equal to nrow(x), containing the groupings for each row of x.

Value

A DFrame where each row corresponds to a level of grouping. Each column corresponds to a column of x and contains the unique value for each group, or NA if no such value exists.

Author(s)

Aaron Lun

Examples

x <- DataFrame(
   foo = rep(LETTERS[1:3], 10),
   bar = rep(letters[1:3], 10),
   val = sample(3, 30, replace=TRUE)
)
uniquifyDataFrameByGroup(x, x$foo)
uniquifyDataFrameByGroup(x, x$val)


LTLA/scuttle documentation built on Oct. 28, 2024, 9:45 a.m.