R users
I have a data frame similar to this:
a <- c(\"John, 3 years\")
b <- c(\"Mokobe, 11 years\")
c <- c(\"Ivan\")
df <- rbind(a,b,c)
df
we can do a strsplit
by the delimiter ,
and then rbind
the list
elements after padding with NA
at the end to make length
same for each list
element
lst <- strsplit(df[,1], ", ")
do.call(rbind, lapply(lst, `length<-`, max(lengths(lst))))
# [,1] [,2]
#a "John" "3 years"
#b "Mokobe" "11 years"
#c "Ivan" NA