Reputation: 3608
I want to print to the screen double quotes (") in R, but it is not working. Typical regex escape characters are not working:
> print('"')
[1] "\""
> print('\"')
[1] "\""
> print('/"')
[1] "/\""
> print('`"')
[1] "`\""
> print('"xml"')
[1] "\"xml\""
> print('\"xml\"')
[1] "\"xml\""
> print('\\"xml\\"')
[1] "\\\"xml\\\""
I want it to return:
" "xml" "
which I will then use downstream.
Any ideas?
Upvotes: 9
Views: 16672
Reputation: 1176
With the help of the print
parameter quote
:
print("\" \"xml\" \"", quote = FALSE)
> [1] " "xml" "
or
cat('"')
Upvotes: 9
Reputation: 28257
Use cat
:
cat("\" \"xml\" \"")
OR
cat('" "','xml','" "')
Output:
" "xml" "
Alternative using noqoute
:
noquote(" \" \"xml\" \" ")
Output :
" "xml" "
Another option using dQoute
:
dQuote(" xml ")
Output :
"“ xml ”"
Upvotes: 7