Re: [R] remove substring from each string vector component

2010-03-16 Thread Marc Schwartz
On Mar 16, 2010, at 9:50 AM, arnaud chozo wrote: > Hi all, > > I have a string vector like that: x=c("1\t\t", "2", "3\t\t\t") > I need to remove all the occurrences of "\t", in order to obtain: x = "1" > "2" "3" > > I'm trying to use the function substring2, and it works for each component, >

Re: [R] remove substring from each string vector component

2010-03-16 Thread Miguel Porto
Hi! It's just this easy: x=gsub("\t","",x) For more complex things, it's worth learning some regular expressions syntax. Miguel On Tue, Mar 16, 2010 at 2:50 PM, arnaud chozo wrote: > Hi all, > > I have a string vector like that: x=c("1\t\t", "2", "3\t\t\t") > I need to remove all the occurrenc

Re: [R] remove substring from each string vector component

2010-03-16 Thread Eik Vettorazzi
Hi Arnaud, how about this: x=c("1\t\t", "2", "3\t\t\t") gsub("\t","",x) hth. arnaud chozo schrieb: Hi all, I have a string vector like that: x=c("1\t\t", "2", "3\t\t\t") I need to remove all the occurrences of "\t", in order to obtain: x = "1" "2" "3" I'm trying to use the function substr

[R] remove substring from each string vector component

2010-03-16 Thread arnaud chozo
Hi all, I have a string vector like that: x=c("1\t\t", "2", "3\t\t\t") I need to remove all the occurrences of "\t", in order to obtain: x = "1" "2" "3" I'm trying to use the function substring2, and it works for each component, for example: substring2(x[1], "\t") ="" gives x = "1" "2" " 3\