Re: [R] replaing 1-digit months with 2-digit months in a date

2010-11-09 Thread Henrique Dallazuanna
Maybe: gsub("\\.(\\d{1}\\s)", ".0\\1", x) On Tue, Nov 9, 2010 at 3:43 PM, Dimitri Liakhovitski < dimitri.liakhovit...@gmail.com> wrote: > Thanks a lot, Henrique, > but I realised, my strings look a bit more complicated, like this: > x<-c("starts 2000.1 some words","starts 2001.2 different > wo

Re: [R] replaing 1-digit months with 2-digit months in a date

2010-11-09 Thread Dimitri Liakhovitski
Thanks a lot, Henrique, but I realised, my strings look a bit more complicated, like this: x<-c("starts 2000.1 some words","starts 2001.2 different words","starts 2008.10 other stuff","starts 2010.12 sth else") I tried to modify the gsub statement but can't get it working. Thank you for your help!

Re: [R] replaing 1-digit months with 2-digit months in a date

2010-11-09 Thread Henrique Dallazuanna
Try this: gsub("\\.(\\d{1}$)", ".0\\1", x) On Tue, Nov 9, 2010 at 3:28 PM, Dimitri Liakhovitski < dimitri.liakhovit...@gmail.com> wrote: > Hello again! > > Sorry, if it's a simple question - I am very bad in working with strings. > > I have a vector of strings: > x<-c("2000.1","2000.2","2000.10"

[R] replaing 1-digit months with 2-digit months in a date

2010-11-09 Thread Dimitri Liakhovitski
Hello again! Sorry, if it's a simple question - I am very bad in working with strings. I have a vector of strings: x<-c("2000.1","2000.2","2000.10","2000.12") I'd like to change it so that it the month always has 2 digits, like this: "2000.01","2000.02","2000.10","2000.12" Is it possible? Tha