[R] detect escape character
sarah.goslee at gmail.com
Tue Jun 3 20:18:14 CEST 2014
R uses \ as a metacharacter, so you need a non-intuitive number of \:
mystring <- "Man\\Woman"
# \\ is a metacharacter and a \, so it's equivalent to \ in normal text
sub("\\\\", "/", mystring)
On Tue, Jun 3, 2014 at 2:03 PM, Adrian Dușa <dusa.adrian at unibuc.ro> wrote:
> Dear All,
> I should be knowing this, but not get it right... For a string like this:
> I would like to detect the escape character "\" and replace it with "/".
> Tried various ways using gsub(), but don't get it right yet. Any suggestion
> would be highly welcomed...
> Thank you,
More information about the R-help