[R] splitting a character field in R

2005-10-28 Thread ManuelPerera-Chang
Dear R users, I have a dataframe with one character field, and I would like to create two new fields (columns) in my dataset, by spliting the existing character field into two using an existing substring. ... something that in SAS I could solve e.g. combining substr(which I am aware exist in

Re: [R] splitting a character field in R

2005-10-28 Thread jim holtman
> x <- 'dfabcxy' > strsplit(x, 'abc') [[1]] [1] "df" "xy" > On 10/28/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > > Dear R users, > > I have a dataframe with one character field, and I would like to create > two > new fields (columns) in my dataset, by spliting the existing charact

Re: [R] splitting a character field in R

2005-10-28 Thread Florence Combes
see sub() and gsub(), but it won't be straightforward as somethink like "string(dataframe)", ie you'll have to 1st treat the character object with sub() or gsub() and 2d rebuils a dataframe. hope this helps Florence. On 10/28/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > > Dear R u

Re: [R] splitting a character field in R

2005-10-28 Thread ManuelPerera-Chang
<[EMAIL PROTECTED]To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> om> cc: r-help@stat.math.ethz.ch

Re: [R] splitting a character field in R

2005-10-28 Thread Gabor Grothendieck
is a list with three elements. But how > to create the two vectors I need from here, that is > > ("dg","fgrt", "s") and ("rt","","uuu") > > (or how to get access to the substrings "rt" or "uuu").

Re: [R] splitting a character field in R

2005-10-28 Thread Dimitris Rizopoulos
n.be/~m0390867/dimitris.htm - Original Message - From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: Sent: Friday, October 28, 2005 4:38 PM Subject: Re: [R] splitting a character field in R > > > > > Hi Jim, > > Thanks for your post, I was aware of st

Re: [R] splitting a character field in R

2005-10-28 Thread jim holtman
[1] "dg" "rt" > > [[2]] > [1] "fgrt" > > [[3]] > [1] "s" "uuu" > > Which looks promissing, but here C is a list with three elements. But how > to create the two vectors I need from here, that is > > ("dg","

Re: [R] splitting a character field in R

2005-10-28 Thread Na Li
On 28 Oct 2005, [EMAIL PROTECTED] wrote: > A<-c(1,2,3) > B<-c("dgabcrt","fgrtabc","sabcuuu") > C<-strsplit(B,"abc") > > C > [[1]] > [1] "dg" "rt" > > [[2]] > [1] "fgrt" > > [[3]] > [1] "s" "uuu" > > Which looks promissing, but here C is a list with three elements. But how > to create the two

Re: [R] splitting a character field in R

2005-10-29 Thread Gabor Grothendieck
elements. But how > > to create the two vectors I need from here, that is > > > > ("dg","fgrt", "s") and ("rt","","uuu") > > > > (or how to get access to the substrings "rt" or "uuu"). &g