I have a large data frame (1616610 rows, 255 columns) and I need to paste together the unique values of each column based on a key.
For example:
>
Moved from comments:
library(data.table) dt <- as.data.table(data) dt[, lapply(.SD, function(x) toString(unique(x))), by = a]
giving:
a b c d 1: 1 apples, oranges 12, 22 Monday 2: 2 apples 45, 67 Tuesday, Wednesday 3: 3 grapefruit 28 Tuesday