Search code examples
rstringquotesbackslash

Remove Backslash and Quotations in R


How do I remove the quotes from the following string in R?

test = "\"LAST4\""
noquote(test)
[1] "LAST4"

I'm reading in the data manually and I can't remove the quotations and backslashes.


Solution

  • You don't need to escape anything if you don't use a regex:

    gsub('\"', "", test, fixed = TRUE)
    #[1] "LAST4"