collapse | R Documentation |
Alternative to interaction
(which can be quite slow) to aggregate columns of a dataset.
collapse.data.frame(object, sep = ".", as.factor = TRUE, ...)
collapse.list(object, sep = ".", as.factor = TRUE, ...)
collapse.matrix(object, ...)
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.½ |
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.