To use double quotes within double quotes in R, use the backslash in front of each quote surrounding your text. It will look like:
While you can typically get the same result by using single quotation marks instead of double, there may be situations where single doesn’t cut it. I ran into this issue recently using the package sqldf to utilize SQL code in R. The specific code I was using broke if I used single quotation marks, so I used this workaround instead.
An example of what this looks like in a SQL SELECT statement:
Example
Here is a full example using test data with the statement above. The output my_data includes the double quotes within double quotes, and my_data2 shows the same result with single quotes.