[R] replacing period with a space

Jason Rupert jasonkrupert at yahoo.com
Tue Oct 13 21:03:56 CEST 2009


Here is one more that works:
gsub("."," ","Start.Time", fixed = TRUE)

"fixed = TRUE" really helps in a lot of instances for removing specific characters without accidently angering the regular expression gods. 

Enjoy. 



--- On Tue, 10/13/09, Dimitri Liakhovitski <ld7631 at gmail.com> wrote:

> From: Dimitri Liakhovitski <ld7631 at gmail.com>
> Subject: [R] replacing period with a space
> To: "R-Help List" <r-help at stat.math.ethz.ch>
> 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","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.
>




More information about the R-help mailing list