Skip to content
Prev 256918 / 398506 Next

Creating a dataframe from a vector of character strings

You could use ?unlist:

structure(data.frame(
    matrix(unlist(strsplit(beatles," ")),length(beatles),2,T)),
    names=c("FirstName","LastName"))

Note that this compact code does not guard you against typos, that is
names with >2 or <2 elements.

Hope that helps,
Denes