RowGroups: Create numbering according to unique rows

View source: R/RowGroups.R

RowGroupsR Documentation

Create numbering according to unique rows

Description

Create numbering according to unique rows

Usage

RowGroups(
  x,
  returnGroups = FALSE,
  returnGroupsId = FALSE,
  NAomit = FALSE,
  pkg = "base"
)

Arguments

x

Data frame or matrix

returnGroups

When TRUE unique rows are returned

returnGroupsId

When TRUE Index of unique rows are returned

NAomit

When TRUE, rows containing NAs are omitted, and the corresponding index numbers are set to NA.

pkg

A character string indicating which package to use. Must be either "base" for base R or "data.table" for data.table. Default is "base".

Value

A vector with the numbering or, according to the arguments, a list with more output.

Author(s)

Øyvind Langsrud

Examples

a <- data.frame(x = c("a", "b"), y = c("A", "B", "A"), z = rep(1:4, 3))
RowGroups(a)
RowGroups(a, TRUE)
RowGroups(a[, 1:2], TRUE, TRUE)
RowGroups(a[, 1, drop = FALSE], TRUE)

SSBtools documentation built on Oct. 30, 2024, 5:09 p.m.

Related to RowGroups in SSBtools...