Re: [R] substract start from the end of the vector

2010-04-23 Thread Steve Lianoglou
On Fri, Apr 23, 2010 at 12:28 PM, arnaud Gaboury wrote: > TY Steve, using regular expression does the job nicely. I need now to fully > understand your code and learn more about what a regular expression is. Any > good ref is welcome. Skimming through the help pages for ?regex and a quick google

Re: [R] substract start from the end of the vector

2010-04-23 Thread arnaud Gaboury
23, 2010 6:11 PM > To: arnaud Gaboury > Cc: r-help@r-project.org > Subject: Re: [R] substract start from the end of the vector > > Hi, > > On Fri, Apr 23, 2010 at 11:57 AM, arnaud Gaboury > wrote: > > Dear group, > > > > Here is my df : > > >

Re: [R] substract start from the end of the vector

2010-04-23 Thread Steve Lianoglou
Hi, On Fri, Apr 23, 2010 at 11:57 AM, arnaud Gaboury wrote: > Dear group, > > Here is my df : > > df <- > > structure(list(DESCRIPTION = c("PRM HGH GD ALUMINIUM USD 09/07/10 ", > > "PRM HGH GD ALUMINIUM USD 09/07/10 ", "PRIMARY NICKEL USD 04/06/10 " > > ), CREATED.DATE = structure(c(18361, 18361,

Re: [R] substract start from the end of the vector

2010-04-23 Thread jim holtman
Use regular expressions: > df$newDesc <- sub("(\\d+/\\d+/\\d +)", '', df$DESCRIPTION) > df DESCRIPTION CREATED.DATE QUANITY CLOSING.PRICEnewDesc 1 PRM HGH GD ALUMINIUM USD 09/07/102020-04-09 -1 2,415.90 PRM HGH GD ALUMINIUM USD 2 PRM HGH G

Re: [R] substract start from the end of the vector

2010-04-23 Thread Chuck Cleland
with(df, substr(DESCRIPTION, start=1, stop=nchar(DESCRIPTION) - 10)) ?nchar On 4/23/2010 11:57 AM, arnaud Gaboury wrote: > Dear group, > > > > Here is my df : > > > > df <- > > structure(list(DESCRIPTION = c("PRM HGH GD ALUMINIUM USD 09/07/10 ", > > "PRM HGH GD ALUMINIUM USD 09/07/10 "

[R] substract start from the end of the vector

2010-04-23 Thread arnaud Gaboury
Dear group, Here is my df : df <- structure(list(DESCRIPTION = c("PRM HGH GD ALUMINIUM USD 09/07/10 ", "PRM HGH GD ALUMINIUM USD 09/07/10 ", "PRIMARY NICKEL USD 04/06/10 " ), CREATED.DATE = structure(c(18361, 18361, 18325), class = "Date"), QUANITY = c(-1L, 1L, 1L), CLOSING.PRICE