I looking for a way to efficiently apply a function to each row of data.table. Let\'s consider the following data table:
library(data.table) library(stringr)
One option would be to add a row number
x[, r := 1:nrow(x)]
and then group by r:
r
x[, list(a, str_split(b, ' ')[[1]]), by = r]
I'm wondering if there are better solutions?