We can try:
res <- lapply(strsplit(dt$foo, ';'), function(x){
res <- tstrsplit(x, '=')
setNames(as.list(res[[2]]), res[[1]])
})
rbindlist(res, fill = T)
dplyr::bind_rows(res)
, , fixed = TRUE strsplit. , , fixed = TRUE .
library(microbenchmark)
dt <- dt[sample.int(nrow(dt), 100, replace = T)]
microbenchmark(
noFix = {
res <- lapply(strsplit(dt$foo, ';'), function(x){
res <- tstrsplit(x, '=')
setNames(as.list(res[[2]]), res[[1]])
})
},
Fixed = {
res <- lapply(strsplit(dt$foo, ';', fixed = TRUE), function(x){
res <- tstrsplit(x, '=', fixed = TRUE)
setNames(as.list(res[[2]]), res[[1]])
})
},
times = 1000
)