Skip to content
Prev 385426 / 398506 Next

Matching backslash in a table's column using R language

1. I am far from an expert on such matters
2. It is unclear to me what your input is -- I assume a file.

The problem, as you indicate, is that R's parser sees "\B" as an incorrect
escape character, so, for example:
Error: '\B' is an unrecognized escape in character string starting ""\B"

In any case, I think you should look at ?scan. Here is an example where I
scan from the keyboard first and then remove the "\". You may have to scan
from a file to do this.
1: A\BCDEFG
2:     #CR terminates input
Read 1 item
A\BCDEFG
[1] 8  ## scan read in the "\" as a single character from the console.
[1] "ABCDEFG"

There may be better ways to do this, but as I said, I'm no expert.

BTW, in posting here, please post in *plain text,* as the server can mangle
html.

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, Aug 25, 2020 at 9:02 AM Peter Bishop <bishop_peterj at hotmail.com>
wrote:

  
  
Message-ID: <CAGxFJbTvCAMGa_XSTbmXd1VORuZO3rUw3D25THyEgWF2-s_RgQ@mail.gmail.com>
In-Reply-To: <ME2PR01MB3857E156F9173873A3EDD86D83560@ME2PR01MB3857.ausprd01.prod.outlook.com>