First, here are sample data in the form of data.frame
dd<-data.frame( A = c(1L, 2L, 5L), B = c(3L, 4L, 6L), C = c("X1=7;X2=8;X3=9", "X1=10;X2=11;X3=12", "X1=13;X2=14"), stringsAsFactors=F )
Now I define a small helper function for accepting vectors of type c("A=1","B=2") and change them to named vectors such as c(A="1", B="2") .
namev<-function(x) { a<-strsplit(x,"=") setNames(sapply(a,'[',2), sapply(a,'[',1)) }
and now I am doing the transformations
#turn each row into a named vector vv<-lapply(strsplit(dd$C,";"), namev) #find list of all column names nm<-unique(unlist(sapply(vv, names))) #extract data from all rows for every column nv<-do.call(rbind, lapply(vv, '[', nm)) #convert everything to numeric (optional) class(nv)<-"numeric" #rejoin with original data cbind(dd[,-3], nv)
and it gives you
AB X1 X2 X3 1 1 3 7 8 9 2 2 4 10 11 12 3 5 6 13 14 NA