[R] Eval and parse function applied on file path

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Oct 18 23:17:49 CEST 2008


On Sat, 18 Oct 2008, Tomislav Puđa wrote:

> Hi,
> I have problem when evaluating string containing file path.
>
> path <-"inputDirectory='d:\\diplomski_rad\\testOutput\\temp'"
> print(eval(parse(text=path)))
>
> After executing code, I get
>
> [1] "d:diplomski_rad\testOutput\temp"
> Warning messages:
> 1: '\d' is an unrecognized escape in a character string
> 2: unrecognized escape removed from "d:\diplomski_rad\testOutput\temp"
>
> I try different combination but without luck. What's the problem ?

Lack of quoting: you need to esape \ twice, for the parser and for the 
string.  So that means liteally \\\\ .

Why not use '/' for file paths (see both the FAQ and rw-FAQ)?

And why not use
assign("-"inputDirectory", 'd:\\diplomski_rad\\testOutput\\temp')
?

>
> Regards,
> Tomislav
>
> 	[[alternative HTML version deleted]]

Please note that you were asked not to do this.

> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


More information about the R-help mailing list