Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to make R strings verbatim (not escaped)?

Typical example:

path <- "C:/test/path" # great
path <- "C:\\test\\path" # also great
path <- "C:\test\path"

Error: '\p' is an unrecognized escape in character string starting ""C:\test\p"

(of course - \t is actually an escape character.)

Is there any mark that can be used to treat the string as verbatim? Or can it be coded?

It would be really useful when copy/pasting path names in Windows...

like image 939
meow Avatar asked Oct 27 '16 09:10

meow


1 Answers

R 4.0.0 introduces raw strings:

dir <- r"(c:\Program files\R)"

https://stat.ethz.ch/R-manual/R-devel/library/base/html/Quotes.html

https://blog.revolutionanalytics.com/2020/04/r-400-is-released.html

like image 102
meow Avatar answered Nov 22 '22 11:11

meow