[R] Lost backslashes in parse()

David Brahm a215020 at agate.fmr.com
Thu Nov 1 22:39:25 CET 2001

I'm comparing R-1.3.0 on Solaris 2.6 to R-1.3.1 on WindowsNT.  The following
5-line script returns TRUE on Unix but FALSE on NT:

fnam <- tempfile()
txt <- paste("file.exists(\"", fnam, "\")", sep="")
expr <- parse(text=txt)

The issue seems to be that backslashes get lost in the parsing.  A workaround
is to change the 3rd line to the rather ugly:
  txt <- paste("file.exists(\"", gsub("\\\\","\\\\\\\\",fnam), "\")", sep="")

Do you think this is something parse() should handle better?  If not, would it
be preferable for tempfile() to return a forward-slash filename on NT?  How
else could you make this script return TRUE on NT?  Thanks!

			   -- David Brahm (brahm at alum.mit.edu)
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list