Re: [R] split strings in a vector and convert it to a data.frame

2010-02-09 Thread Gabor Grothendieck
On Tue, Feb 9, 2010 at 6:46 PM, Martin Batholdy wrote: > hi, > > I have a vector full of strings like; > > > xy_100_ab       xy_101_ab       xy_102_ab       xy_103_ab > > > I want to seperate each string in three pieces and the separator should be > the "_" > > at the end I want a data.frame like

Re: [R] split strings in a vector and convert it to a data.frame

2010-02-09 Thread David Winsemius
On Feb 9, 2010, at 6:46 PM, Martin Batholdy wrote: hi, I have a vector full of strings like; xy_100_ab xy_101_ab xy_102_ab xy_103_ab I want to seperate each string in three pieces and the separator should be the "_" at the end I want a data.frame like: column1 column

Re: [R] split strings in a vector and convert it to a data.frame

2010-02-09 Thread Jorge Ivan Velez
Hi Martin, Here is a sugestion: string <- c("xy_100_ab", "xy_101_ab","xy_102_ab","xy_103_ab") out <- data.frame( do.call( rbind, strsplit( string, '_' ) ) ) names(out) <- paste('column',1:3,sep="") out HTH, Jorge On Tue, Feb 9, 2010 at 6:46 PM, Martin Batholdy <> wrote: > hi, > > I have a vect

[R] split strings in a vector and convert it to a data.frame

2010-02-09 Thread Martin Batholdy
hi, I have a vector full of strings like; xy_100_ab xy_101_ab xy_102_ab xy_103_ab I want to seperate each string in three pieces and the separator should be the "_" at the end I want a data.frame like: column1 column2 column3 xy 100 ab xy