Vinod P
Vinod P

Reputation: 99

Reading the text file introduces backslash in between

I have a text file(df_copy) that has contains text a shown below

"list(list(a = "1909", v = "No sign", ved = "11"), 
list(a = "1908", v = "Yes sign", ved = "11"))" 

When I read this, it is returning backslash

> asf <- paste0(readLines("df_copy.txt"),collapse=" ")
Warning message:
In readLines("df_Copy.txt") : incomplete final line found on 'df_Copy.txt'
> asf
[1] "\"list(list(a = \"1909\", v = \"No sign\", ved = \"11\"),  list(a = \"1908\", v = \"Yes sign\", ved = \"11\"))\" "

Expected output

"list(list(a = "1909", v = "No sign", ved = "11"),  list(a = "1908", v = "Yes sign", ved = "11"))"

Upvotes: 0

Views: 338

Answers (1)

akrun
akrun

Reputation: 887213

It is just the escape character for double quote. We can check with cat

cat('list(list(a = "1909", v = "No sign", ved = "11"),  list(a = "1908", v = "Yes sign", ved = "11"))')

Upvotes: 1

Related Questions