Short answer:
gsub("\"", "", info360$more)
Explanation:
The backslashes are escape characters for the quotes ("). These need to be escaped, as a character
s in R are enclosed in quotes. Try executing cat(info360$more)
. You'll see that the backslashes disappear, and the one pair of quotes remains. So you want to get rid of the extra pair of quotes, which will also make the backslashes disappear.
Here is a little example. Try to understand why the output of a
and cat(a)
is different. That should help you to solve your issue.
a <- c("\"test\"", '"test2"', "test3")
a
#> [1] "\"test\"" "\"test2\"" "test3"
cat(a)
#> "test" "test2" test3
Hint: The output of cat(a)
displays the "actual" value of a
, while a
produces output that is "decorated" with escape characters, in order to make the output compatible with R code.
The extra pair of quotes most likely is coming from the original data in the CSV file. Can you post the raw CSV in your question? Open it in a text editor, not excel for that purpose.