uniqueP: Unique collapse of character vector

View source: R/uniqueP.R

uniquePR Documentation

Unique collapse of character vector

Description

Paste a character vector's unique values into a single string.

Usage

uniqueP(x, collapse="; ", sort=TRUE)

Arguments

x

character vector.

collapse

character string to be pasted between x elements.

sort

TRUE/FALSE. Sorted the elements alphabetically before being collapsed?

Examples

vec = c("apple","banana","banana","corn","corn","tomato")

uniqueP(vec)

#Use with \emph{data.table} syntax
dt = data.table(group=c("A","A","A","B","B","B","B"), name=c("Mary","Mary","Jim","Bill","Fred","Bill","Anne"))

dt[, uniqueP(name), by=.(group)]



NRGI/nrgiR documentation built on April 3, 2022, 9:20 a.m.