For numeric data take the mean. For character data take the first value.
aggregate_mean_or_first(x)
x
a train object
a data.table::data.table with predictions