collapse: Aggregate Dataset by Columns

collapseR Documentation

Aggregate Dataset by Columns

Description

Alternative to interaction (which can be quite slow) to aggregate columns of a dataset.

Usage

collapse.data.frame(object, sep = ".", as.factor = TRUE, ...)

collapse.list(object, sep = ".", as.factor = TRUE, ...)

collapse.matrix(object, ...)

Arguments

object

dataset

sep

[character] character strings used to concatenate values from different columns.

as.factor

[logical] should the result be converted into a factor or be numeric or character.

...

Not used. For compatibility with the generic method.½

Examples

df1 <- data.frame(var1 = 1:10)
nlme::collapse(df1)

df2 <- data.frame(var1 = 1:10, var2 = -(1:10))
nlme::collapse(df2)
interaction(df2, sep = ".", drop = TRUE)

df3 <- data.frame(var1 = 1:1000, var2 = -(1:1000), var3 = (1:1000)/1000)
test <- nlme::collapse(df3)
GS <- interaction(df3, sep = ".", drop = TRUE)

bozenne/repeated documentation built on July 16, 2025, 11:16 p.m.