[R] replacing period with a space

Henrique Dallazuanna wwwhsd at gmail.com
Tue Oct 13 19:34:36 CEST 2009


You need escape the period:

gsub("\\.", " ", x$x)

On Tue, Oct 13, 2009 at 2:26 PM, Dimitri Liakhovitski <ld7631 at gmail.com> 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 can I replace all
> periods in x$x with spaces?
>
> sub('.', ' ', x$x) - removes all letters to the left of each period...
>
> Thanks a lot for your advice!
>
> --
> Dimitri Liakhovitski
> Ninah.com
> Dimitri.Liakhovitski at ninah.com
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O




More information about the R-help mailing list