ezCollapse: Collapses a vector in a single character

View source: R/util.R

ezCollapseR Documentation

Collapses a vector in a single character

Description

This extends the functionality from paste(..., collapse=...) by optionally removing empty characters, duplicates or NA values

Usage

ezCollapse(x, sep = "; ", na.rm = FALSE, empty.rm = FALSE, uniqueOnly = FALSE)

Arguments

x

a vector, matrix or list.

sep

the separator to use between values.

na.rm

a logical specifying whether to remove NA's.

empty.rm

a logical specifying whether to remove empty values.

uniqueOnly

a logical specifying whether to keep only unique values.

Value

Returns the values collapsed into one character.

Author(s)

Rehrauer, Hubert

Schmid, Peter

Examples

l1 = list(a=c(1,"",6),c=c("rsrg","yjrt",NA,6))
ezCollapse(l1,sep="_")
ezCollapse(l1,na.rm=T,empty.rm=T,uniqueOnly=T)

uzh/ezRun documentation built on Sept. 16, 2024, 11:21 p.m.