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 <miao...@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@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]]

______________________________________________
R-help@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.

Reply via email to