Вот один подход с tstrsplit
, который должен сработать для вас:
library(data.table)
dt[, lapply(.SD, function(x) unlist(tstrsplit(x, "; ?"))),
.SDcols = "sha",by = c("title","date")]
title date sha
1: First Title 1/1/2020 12345
2: Second Title 1/2/2020 2345
3: Second Title 1/2/2020 66543
4: Second Title 1/2/2020 33423
5: Third Title 1/3/2020 22222
6: Third Title 1/3/2020 12345678
7: Fourth Title 1/4/2020 666662345
8: Fourth Title 1/4/2020 444
Data
dt <- data.table("title"=c("First Title", "Second Title", "Third Title", "Fourth Title"),
"sha"=c("12345", "2345; 66543; 33423", "22222; 12345678;", "666662345; 444"),
"date" = c("1/1/2020","1/2/2020","1/3/2020","1/4/2020"))