I am trying to write the following data frame in a file as it appears below (i.e. keeping the '\t' and '\n' as plain text).
df <- data.frame(Col1 = quote("A\tB"), Col2=quote("C\nD"))
df
Col1 Col2
1 A\tB C\nD
Doing write.table(df, "my_file.tab", quote=F, sep="\t", row.names=F) produces a file containing the following:
Col1 Col2
A B C
D
instead of:
Col1 Col2
A\tB C\nD
or, if not possible without unquoting:
Col1 Col2
"A\tB" "C\nD"