I have a character vector which includes regex
special characters such as \n
.
I want to save this vector to a txt-file which shows the \n
.
The code below creates a txt file, but when opening the file e.g. in notepad, the \n
are translated into linebreaks. I don't want to see the linebreaks, I want to see \n
.
library(tidyverse)
my_text <- "hello\n, nice to meet you.\n\n. how are you?"
my_text
readr::write_file(my_text, "my_text.txt")
this is what notepad shows:
hello
, nice to meet you.
. how are you?
but I want to see
"hello\n, nice to meet you.\n\n. how are you?"
I thought there was some kind of 'raw option', but seems like I am wrong. Thx!