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 =
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
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
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
4 matches
Mail list logo