[R] Creating a dataframe from a vector of character strings

2011-04-14 Thread Cliff Clive
I have a vector of character strings that I would like to split in two, and place in columns of a dataframe. So for example, I start with this: beatles - c(John Lennon, Paul McCartney, George Harrison, Ringo Starr) and I want to end up with a data frame that looks like this: Beatles =

Re: [R] Creating a dataframe from a vector of character strings

2011-04-14 Thread Tóth Dénes
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 I have a vector of character

Re: [R] Creating a dataframe from a vector of character strings

2011-04-14 Thread Rolf Turner
On 15/04/11 09:04, Cliff Clive wrote: I have a vector of character strings that I would like to split in two, and place in columns of a dataframe. So for example, I start with this: beatles- c(John Lennon, Paul McCartney, George Harrison, Ringo Starr) and I want to end up with a data frame

Re: [R] Creating a dataframe from a vector of character strings

2011-04-14 Thread Brian Diggs
On 4/14/2011 2:04 PM, Cliff Clive wrote: I have a vector of character strings that I would like to split in two, and place in columns of a dataframe. So for example, I start with this: beatles- c(John Lennon, Paul McCartney, George Harrison, Ringo Starr) and I want to end up with a data frame