[R] Replace a dot in a string (".") with a space (" ")
Omar André Gonzáles Díaz
oma.gonzales at gmail.com
Sat Nov 19 01:20:26 CET 2016
Hi, your were close.
This is the solution:
sub("[.]", " ", "c.t")
You need to scape the point, because point has a especial meaning in
regular expressions. Read more on regex...
2016-11-18 19:13 GMT-05:00 John <miaojpm at gmail.com>:
> Hi,
>
> Is there any function that replaces a dot with a space? I expect "c t"
> from the output of the second call of function sub, but it did not do so.
>
> > sub("a", "b", "cat")
> [1] "cbt"
> > sub(".", " ", "c.t")
> [1] " .t"
>
> Thanks!
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list