Reputation: 5935
I am using the R programming language. I am copying text data from a website that contains many quotation marks, i.e. "" . When I try to create a data frame that contains this text, I will get an error because of conflicting "" symbols.
For example:
a <- " "blah" blah blah"
Error: unexpected symbol in "a <- " "blah"
Normally, I would have tried to use the gsub() function to remove these quotation marks from the data frame, but I can not even create the data frame to begin with. Of course, I could bring this text into a word processing software and click " ctrl + H" to replace all quotation marks ("") with an empty space (). But is there a way to do this in R itself?
Thanks
Upvotes: 0
Views: 231
Reputation: 522646
The typical way you would handle this would be to escape the literal double quotes with backslash:
a <- " \"blah\" blah blah"
[1] " \"blah\" blah blah"
You could also wrap your string literal inside single quotes and then not even have to escape the double quotes:
a <- ' \"blah\" blah blah'
[1] " \"blah\" blah blah"
Upvotes: 1