[R] File path expansion

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri May 25 19:09:10 CEST 2007

On Fri, 25 May 2007, Martin Maechler wrote:

>> path.expand("~")
> [1] "/home/maechler"

Yes, but beware that may not do what you want on Windows in R <= 2.5.0, 
since someone changed the definition of 'home' but not path.expand.

>>>>>> "RobMcG" == McGehee, Robert <Robert.McGehee at geodecapital.com>
>>>>>>     on Fri, 25 May 2007 11:44:27 -0400 writes:
>    RobMcG> R-Help,
>    RobMcG> I discovered a "mis-feature" is ghostscript, which is used by the bitmap
>    RobMcG> function. It seems that specifying file names in the form "~/abc.png"
>    RobMcG> rather than "/home/directory/abc.png" causes my GS to crash when I open
>    RobMcG> the bitmap device on my Linux box.
>    RobMcG> The easiest solution would seem to be to intercept any file names in the
>    RobMcG> form "~/abc.png" and replace the "~" with the user's home directory. I'm
>    RobMcG> sure I could come up with something involving regular expressions and
>    RobMcG> system calls to do this in Linux, but even that might not be system
>    RobMcG> independent. So, I wanted to see if anyone knew of a native R solution
>    RobMcG> of converting "~" to its full path expansion.
>    RobMcG> Thanks,
>    RobMcG> Robert
> ______________________________________________
> R-help at stat.math.ethz.ch 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