base R
のみを使用してください。
fun <- function(x){
sp <- unlist(strsplit(x, ";"))
sp <- strsplit(sp, ":")
sp <- unlist(lapply(sp, function(x) setNames(x[2], x[1])))
sp[order(names(sp))]
}
result <- as.data.frame(t(sapply(dat, fun)))
row.names(result) <- NULL
result
# city name tel
#1 London Alyce 270167423
#2 Manchester Sabine 377658186
#3 Warsaw John 182601043
#4 Brno Alex 313976092
#5 Dehli Tom 152764798
データです。
dat <-
c("city:London;tel:270167423;name:Alyce", "tel:377658186;city:Manchester;name:Sabine",
"city:Warsaw;name:John;tel:182601043", "city:Brno;tel:313976092;name:Alex",
"name:Tom;tel:152764798;city:Dehli")