Re: [R] replacing period with a space

2009-10-13 Thread Don MacQueen
There is also the fixed argument to gsub (read the help page!) gsub('.', ' ','a.b',fixed=TRUE) [1] "a b" -Don At 2:34 PM -0300 10/13/09, Henrique Dallazuanna wrote: You need escape the period: gsub("\\.", " ", x$x) On Tue, Oct 13, 2009 at 2:26 PM, Dimitri Liakhovitski wrote: Dear R-er

Re: [R] replacing period with a space

2009-10-13 Thread Gabor Grothendieck
Try chartr: > chartr(".", " ", "a.b.c") [1] "a b c" On Tue, Oct 13, 2009 at 1:26 PM, Dimitri Liakhovitski wrote: > Dear R-ers! > > I have x as a variable in a data frame x. > > x<-data.frame(x=c("aa.bb","cc.dd.ee")) > x$x<-as.character(x$x) > x > > I am sorry for such a simple question - but how

Re: [R] replacing period with a space

2009-10-13 Thread Jason Rupert
ri Liakhovitski wrote: > From: Dimitri Liakhovitski > Subject: [R] replacing period with a space > To: "R-Help List" > Date: Tuesday, October 13, 2009, 12:26 PM > Dear R-ers! > > I have x as a variable in a data frame x. > > x<-data.frame(x=c("aa.bb&

Re: [R] replacing period with a space

2009-10-13 Thread Dimitri Liakhovitski
Thanks a lot for your help, Henrique and Sarah! Dimitri On Tue, Oct 13, 2009 at 1:37 PM, Sarah Goslee wrote: > As you've discovered, the . means something special in regular > expressions (and R's version of them). You need to escape it with \\: > >> x<-data.frame(x=c("aa.bb","cc.dd.ee")) >> x$x<

Re: [R] replacing period with a space

2009-10-13 Thread Henrique Dallazuanna
You need escape the period: gsub("\\.", " ", x$x) On Tue, Oct 13, 2009 at 2:26 PM, Dimitri Liakhovitski wrote: > Dear R-ers! > > I have x as a variable in a data frame x. > > x<-data.frame(x=c("aa.bb","cc.dd.ee")) > x$x<-as.character(x$x) > x > > I am sorry for such a simple question - but how c

Re: [R] replacing period with a space

2009-10-13 Thread Sarah Goslee
As you've discovered, the . means something special in regular expressions (and R's version of them). You need to escape it with \\: > x<-data.frame(x=c("aa.bb","cc.dd.ee")) > x$x<-as.character(x$x) > x x 1aa.bb 2 cc.dd.ee > sub("\\.", " ", x$x) [1] "aa bb""cc dd.ee" > gsub("\\.",

[R] replacing period with a space

2009-10-13 Thread Dimitri Liakhovitski
Dear R-ers! I have x as a variable in a data frame x. x<-data.frame(x=c("aa.bb","cc.dd.ee")) x$x<-as.character(x$x) x I am sorry for such a simple question - but how can I replace all periods in x$x with spaces? sub('.', ' ', x$x) - removes all letters to the left of each period... Thanks a lo