Here is the basic solution of R. Separate the PolId field using strplit , and for each such separation field, bind it to the corresponding Description . This gives a list of matrices that we rbind together. Finally, specify the column names.
out <- do.call(rbind, Map(cbind, strsplit(DF$PolId, ";"), DF$Description)) colnames(out) <- colnames(DF)
giving:
> out PolId Description [1,] "ABC123" "TEST1" [2,] "ABC456" "TEST1" [3,] "ABC789" "TEST1" [4,] "ABC123" "TEST1" [5,] "ABC456" "TEST1" [6,] "ABC789" "TEST1" [7,] "ABC123" "TEST1" [8,] "ABC456" "TEST1" [9,] "ABC789" "TEST1" [10,] "AAA123" "TEST1" [11,] "AAA123" "TEST2" [12,] "ABB123" "TEST3" [13,] "ABC123" "TEST3" [14,] "ABB123" "TEST3" [15,] "ABC123" "TEST3"
Note: We used this as input:
DF <- structure(list(PolId = c("ABC123;ABC456;ABC789;", "ABC123;ABC456;ABC789;", "ABC123;ABC456;ABC789;", "AAA123;", "AAA123;", "ABB123;ABC123;", "ABB123;ABC123;"), Description = c("TEST1", "TEST1", "TEST1", "TEST1", "TEST2", "TEST3", "TEST3")), .Names = c("PolId", "Description" ), class = "data.frame", row.names = c(NA, -7L))