Wednesday, March 27, 2013 5:17 PM
> To: Shane Carey
> Cc: r-help@r-project.org
> Subject: Re: [R] find and replace characters in a string
>
> Hello,
>
> The period is a metacharacter so you have to escape it.
> The period is escaped with a '\'. In it's turn,
Hello,
The period is a metacharacter so you have to escape it.
The period is escaped with a '\'. In it's turn, '\' is a metacharacter
so it needs to be escaped. Hence the double'\\'.
x <- "LOI ."
gsub("\\.", "(%)", x)
Hope this helps,
Rui Barradas
Em 27-03-2013 16:09, Shane Carey escreveu:
txt<- "LOI ."
gsub("[.]","%",txt)
#[1] "LOI %"
A.K.
From: Shane Carey
To: r-help@r-project.org
Sent: Wednesday, March 27, 2013 12:09 PM
Subject: [R] find and replace characters in a string
Hi,
I have a string o
Hi,
I have a string of text as follows "LOI ."
How do I replace the dot with "(%)"
gsub(".","(%)",LOI .)
gives
"(%)(%)(%)(%)(%)"
Thanks
--
Shane
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.c
4 matches
Mail list logo