uniqueP: Unique collapse of character vector

Description Usage Arguments Examples

View source: R/uniqueP.R

Description

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

Usage

1
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

1
2
3
4
5
6
7
8
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 Dec. 14, 2018, 3:02 p.m.